Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  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. var bodyParser = require('body-parser')
  8.  
  9.  
  10. // parse application/x-www-form-urlencoded
  11. app.use(bodyParser.urlencoded({ extended: false }))
  12.  
  13.  
  14. // If you are producing a combined Web + Mobile app, then you should handle
  15. // anything like logging, registering middleware, etc. here
  16.  
  17. // Configuration of the Azure Mobile Apps can be done via an object, the
  18. // environment or an auxiliary file. For more information, see
  19. var users = [{email: 'a', pass: 'a'}];
  20. // Import the files from the tables directory to configure the /tables endpoint
  21.  
  22. var mobileApp = azureMobileApps({
  23. // Explicitly enable the Azure Mobile Apps home page
  24. homePage: true,
  25. // Explicitly enable swagger support. UI support is enabled by
  26. // installing the swagger-ui npm module.
  27. swagger: true
  28. });
  29. mobileApp.api.import('./api');
  30.  
  31. app.use(mobileApp);
  32. app.listen(process.env.PORT || 3000);
  33.  
  34.  
  35. app.post('/auth', function(req, res){
  36. var status = 401;
  37. console.log(req);
  38. var response = { status: false, user: {} };
  39. response.user = req.body;
  40. var user = verifyLogin(req.body.email, req.body.pass);
  41. if(user){
  42. response.status = true;
  43. status = 200;
  44. }
  45. res.status(status).json(response);
  46. });
  47.  
  48. //////////////////////////////////////////////////////////////
  49.  
  50. function verifyLogin(email, pass){
  51. for(var i=0; i<1; i++){
  52. if(users[i].email == email && users[i].pass == pass){
  53. return true;
  54. }
  55. }
  56. return false;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement