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') | |
.factory('AuthService', ['$http', | |
function($http) { | |
var AuthService = {}; | |
AuthService.login = function(data) { | |
return $http.post('/login', data) | |
} |
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') | |
.directive('logout', ['$http', function($http) { | |
return { | |
restrict: 'A', | |
link: function(scope, element, attrs) { | |
element.on('click', function(e) { | |
$http.post('/logout'); | |
}); | |
} |
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('ProfileController', ['$http', '$scope', '$location', | |
function($http, $scope, $location) { | |
$http.get('/api/userData') | |
.success(function(response) { | |
console.log('user data success') | |
console.log(response) | |
$scope.user = response; //Expose the user data to your angular scope | |
}) |
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
.when('/profile', { | |
templateUrl: '/views/profile.html', | |
controller: 'ProfileController' | |
}) |
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="page-header text-center"> | |
<h1><span class="fa fa-anchor"></span> Profile Page</h1> | |
<a logout href="/logout" class="btn btn-default btn-sm">Logout</a> | |
</div> | |
<div class="row"> | |
<!-- LOCAL INFORMATION --> | |
<div class="col-sm-12"> | |
<div class="well"> |
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); | |
} |
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
(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
// 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
// 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']); | |
})(); |