This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"dependencies": { | |
"passport": "^0.3.2", | |
"passport-local": "^1.0.0" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var passport = require('passport'); | |
var cookieParser = require('cookie-parser'); | |
var session = require('express-session'); | |
app.use(session({ | |
secret: 'this is the secret', | |
resave: true, | |
saveUninitialized: true | |
})); | |
app.use(cookieParser()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var passport = require('passport'); | |
var auth = authorized; | |
app.post ('/api/login', passport.authenticate('local'), login); | |
app.post ('/api/logout', logout); | |
app.post ('/api/register', register); | |
app.post ('/api/user', auth, createUser); | |
app.get ('/api/loggedin', loggedin); | |
app.get ('/api/user', auth, findAllUsers); | |
app.put ('/api/user/:id', auth, updateUser); | |
app.delete('/api/user/:id', auth, deleteUser); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var userModel = require("../../models/user/user.model.server.js")(); | |
var LocalStrategy = require('passport-local').Strategy; | |
passport.use(new LocalStrategy(localStrategy)); | |
function localStrategy(username, password, done) { | |
userModel | |
.findUserByCredentials({username: username, password: password}) | |
.then( | |
function(user) { | |
if (!user) { return done(null, false); } | |
return done(null, user); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
passport.serializeUser(serializeUser); | |
passport.deserializeUser(deserializeUser); | |
function serializeUser(user, done) { | |
done(null, user); | |
} | |
function deserializeUser(user, done) { | |
userModel | |
.findUserById(user._id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function login(req, res) { | |
var user = req.user; | |
res.json(user); | |
} | |
function logout(req, res) { | |
req.logOut(); | |
res.send(200); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.js | |
(function() { | |
angular | |
.module("EmployeeApp") | |
.config(Config); | |
function Config(<--1--> ) { | |
$routeProvider | |
.when("/user/:uid", { | |
template: "user.view.html", | |
controller: "UserController" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"meta": { | |
"grade": { | |
"list": [ | |
"9", | |
"10", | |
"11", | |
"12" | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "123", | |
"title": "CS5610", | |
"modules": [ | |
{ | |
"title": "Week 1", | |
"lessons": [ | |
{ | |
"title": "HTML", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "123", | |
"username": "alice", | |
"password": "alice", | |
"email": "alice@wonderland.com", | |
"firstName": "Alice", | |
"lastName": "Wonderland", | |
"role": "FACULTY" | |
}, |
OlderNewer