Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var express = require('express'),
- azureMobileApps = require('azure-mobile-apps');
- // Set up a standard Express app
- var app = express();
- var bodyParser = require('body-parser')
- // parse application/x-www-form-urlencoded
- app.use(bodyParser.urlencoded({ extended: false }))
- // If you are producing a combined Web + Mobile app, then you should handle
- // anything like logging, registering middleware, etc. here
- // Configuration of the Azure Mobile Apps can be done via an object, the
- // environment or an auxiliary file. For more information, see
- var users = [{email: 'a', pass: 'a'}];
- // Import the files from the tables directory to configure the /tables endpoint
- var mobileApp = azureMobileApps({
- // Explicitly enable the Azure Mobile Apps home page
- homePage: true,
- // Explicitly enable swagger support. UI support is enabled by
- // installing the swagger-ui npm module.
- swagger: true
- });
- mobileApp.api.import('./api');
- app.use(mobileApp);
- app.listen(process.env.PORT || 3000);
- app.post('/auth', function(req, res){
- var status = 401;
- console.log(req);
- var response = { status: false, user: {} };
- response.user = req.body;
- var user = verifyLogin(req.body.email, req.body.pass);
- if(user){
- response.status = true;
- status = 200;
- }
- res.status(status).json(response);
- });
- //////////////////////////////////////////////////////////////
- function verifyLogin(email, pass){
- for(var i=0; i<1; i++){
- if(users[i].email == email && users[i].pass == pass){
- return true;
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement