Advertisement
Guest User

Untitled

a guest
Nov 18th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var express = require('express'),
  2.     azureMobileApps = require('azure-mobile-apps');
  3.  
  4. // Set up a standard Express app
  5. var app = express();
  6.  
  7.  
  8.  
  9. // If you are producing a combined Web + Mobile app, then you should handle
  10. // anything like logging, registering middleware, etc. here
  11.  
  12. // Configuration of the Azure Mobile Apps can be done via an object, the
  13. // environment or an auxiliary file.  For more information, see
  14. var users = [{email: 'a', pass: 'a'}];
  15. // Import the files from the tables directory to configure the /tables endpoint
  16.  
  17. var mobileApp = azureMobileApps({
  18.     // Explicitly enable the Azure Mobile Apps home page
  19.     homePage: true,
  20.     // Explicitly enable swagger support. UI support is enabled by
  21.     // installing the swagger-ui npm module.
  22.     //swagger: true
  23. });
  24. mobileApp.api.import('./api');
  25.  
  26. app.post('/auth', function(req, res){
  27.     var status = 401;
  28.     var success = false;
  29.  
  30.     var user = verifyLogin(req.body.email, req.body.password);
  31.     if(user){
  32.        
  33.         success = true;
  34.  
  35.         status = 200;
  36.     }
  37.     res.status(status).json(response);
  38. });
  39.  
  40. //////////////////////////////////////////////////////////////
  41.  
  42. function verifyLogin(email, pass){
  43.     for(var i=0; i<users.length; i++){
  44.         if(users[i].email == email && users[i].pass == pass){
  45.             return true;
  46.         }
  47.     }
  48.     return false;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement