Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. // app/routes.js
  2.  
  3. var path = require('path');
  4. var bodyParser = require('body-parser');
  5.  
  6. module.exports = function(app) {
  7.  
  8. app.use( bodyParser.json() ); // to support JSON-encoded bodies
  9. app.use(bodyParser.urlencoded({ extended: true // to support URL-encoded bodies
  10. }));
  11.  
  12. app.post('/partner', function(req, res){
  13. var email = req.body.userEmail;
  14. var password = req.body.userPass;
  15.  
  16. console.log(email);
  17. console.log(password);
  18.  
  19. var adminEmail = 'admin';
  20. var adminPassword = 'admin';
  21.  
  22. if (email == adminEmail && password == adminPassword){
  23. var userData = {userEmail: email, userPass: password};
  24. res.json(userData);
  25. }
  26. else if (email == adminEmail && password != adminPassword){
  27. var wrongPassword = {'text': 'Hibás jelszó!', userEmail: email, userPass: password};
  28. res.json(wrongPassword);
  29. }
  30. else {
  31. var wrongData = {'text': 'Hibás email cím vagy jelszó!', userEmail: email, userPass: password};
  32. res.json(wrongData);
  33. }
  34.  
  35. });
  36.  
  37. // server routes ===========================================================
  38. // handle things like api calls
  39. // authentication routes
  40.  
  41. // api route - get all lists and words for a user
  42. // app.get('/api/lists', function(req, res) {
  43.  
  44. // User.find( { username: 'username'}, function(err, user) {
  45. // // if there is an error retrieving, send the error. nothing after res.send(err) will execute
  46. // if (err){
  47. // console.log('Error while looking up user: =====================');
  48. // res.send(err);
  49. // }
  50.  
  51. // console.log('SUCCESS IN looking up user: =====================');
  52.  
  53. // res.json(user); // return all user data in JSON format
  54. // });
  55. // });
  56.  
  57. // frontend routes =========================================================
  58. // route to handle all angular requests
  59. app.get('*', function(req, res) {
  60. res.sendFile('index.html', { root: path.join(__dirname, '../public') }); // load our public/index.html file
  61. });
  62.  
  63. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement