Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // app/routes.js
- var path = require('path');
- var bodyParser = require('body-parser');
- module.exports = function(app) {
- app.use( bodyParser.json() ); // to support JSON-encoded bodies
- app.use(bodyParser.urlencoded({ extended: true // to support URL-encoded bodies
- }));
- app.post('/partner', function(req, res){
- var email = req.body.userEmail;
- var password = req.body.userPass;
- console.log(email);
- console.log(password);
- var adminEmail = 'admin';
- var adminPassword = 'admin';
- if (email == adminEmail && password == adminPassword){
- var userData = {userEmail: email, userPass: password};
- res.json(userData);
- }
- else if (email == adminEmail && password != adminPassword){
- var wrongPassword = {'text': 'Hibás jelszó!', userEmail: email, userPass: password};
- res.json(wrongPassword);
- }
- else {
- var wrongData = {'text': 'Hibás email cím vagy jelszó!', userEmail: email, userPass: password};
- res.json(wrongData);
- }
- });
- // server routes ===========================================================
- // handle things like api calls
- // authentication routes
- // api route - get all lists and words for a user
- // app.get('/api/lists', function(req, res) {
- // User.find( { username: 'username'}, function(err, user) {
- // // if there is an error retrieving, send the error. nothing after res.send(err) will execute
- // if (err){
- // console.log('Error while looking up user: =====================');
- // res.send(err);
- // }
- // console.log('SUCCESS IN looking up user: =====================');
- // res.json(user); // return all user data in JSON format
- // });
- // });
- // frontend routes =========================================================
- // route to handle all angular requests
- app.get('*', function(req, res) {
- res.sendFile('index.html', { root: path.join(__dirname, '../public') }); // load our public/index.html file
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement