This file contains 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
<!doctype html> | |
<html> | |
<head> | |
<title>Node Authentication</title> | |
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css"> | |
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css"> | |
<style> | |
body { padding-top:80px; } | |
</style> | |
</head> |
This file contains 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
<!doctype html> | |
<html ng-app="app"> | |
<head> | |
<title>Node Authentication</title> | |
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css"> | |
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css"> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-route.min.js"></script> | |
<script src="js/app.js"></script> |
This file contains 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
// defining our angular app, the first arguement is the name of our application | |
// second argument is an array that loads the dependencies into the application | |
(function() { | |
angular.module('app', ['ngRoute']); | |
})(); |
This file contains 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
// server.js | |
... | |
app.use(express.static(path.join(__dirname, '/public'))); //Expose /public | |
// routes ====================================================================== | |
require('./app/routes.js')(app, passport); // load our routes and pass in our app and fully configured passport | |
// catch all other routes and have index.html handle them. | |
app.get('*', function (req, res){ | |
res.sendFile(path.join(__dirname+ '/public/views/index.html')); | |
}); |
This file contains 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
// defining our routes | |
(function() { | |
angular.module('app') | |
.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { | |
$routeProvider | |
.when('/', { | |
templateUrl: '/views/landing.html', | |
}) | |
.when('/login', { | |
templateUrl: '/views/login.html', |
This file contains 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
<div class="col-sm-6 col-sm-offset-3"> | |
<h1><span class="fa fa-sign-in"></span> Login</h1> | |
<!-- LOGIN FORM --> | |
<form ng-submit="login.login()" ng-controller="LoginControllerTwo as login"> | |
<div class="form-group"> | |
<label>Email</label> | |
<input type="text" class="form-control" ng-model="login.email"> | |
</div> |
This file contains 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
<div class="col-sm-6 col-sm-offset-3"> | |
<h1><span class="fa fa-sign-in"></span> Signup</h1> | |
<!-- SIGNUP FORM --> | |
<form ng-submit="signup.signup()" ng-controller="SignupController as signup"> | |
<div class="form-group"> | |
<label>Email</label> | |
<input type="text" class="form-control" ng-model="signup.email"> | |
</div> |
This file contains 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() { | |
angular.module('app') | |
.controller('SignupController', ['$http', '$location', | |
function($http, $location) { | |
var vm = this; | |
vm.signup = function() { | |
$http | |
.post('/signup', { | |
email: vm.email, | |
password: vm.password |
This file contains 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() { | |
angular.module('app') | |
.controller('LoginController', ['$http', '$location', | |
function($http, $location) { | |
var vm = this; | |
vm.login = function() { | |
$http | |
.post('/login', { | |
email: vm.email, | |
password: vm.password |
This file contains 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
app.post('/signup', function(req, res, next) { | |
// if email or password is missing, return an error message | |
if (!req.body.email || !req.body.password) { | |
return res.status(400).json({ error: 'Email and Password required' }); | |
} | |
passport.authenticate('local-signup', function(err, user, info) { | |
if (err) { | |
return res.status(400).json(err); | |
} |