Skip to content

Commit 3270725

Browse files
committed
updated angular controllers
added settings page to navbar controller fixed login/settings controllers to match changes to Auth service
1 parent 3187a07 commit 3270725

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

templates/javascript/controllers/login.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ angular.module('<%= scriptAppName %>')
99
$scope.submitted = true;
1010

1111
if(form.$valid) {
12-
Auth.login('local', {
12+
Auth.login({
1313
email: $scope.user.email,
1414
password: $scope.user.password
1515
})
16-
.then( function(user) {
17-
// Success, redirect to home
16+
.then( function() {
17+
// Logged in, redirect to home
1818
$location.path('/');
1919
})
2020
.catch( function(err) {
21-
var err = err.data;
21+
err = err.data;
2222
$scope.errors.other = err.message;
2323
});
2424
}

templates/javascript/controllers/navbar.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@ angular.module('<%= scriptAppName %>')
55
$scope.menu = [{
66
'title': 'Home',
77
'link': '/'
8-
}, {
9-
'title': 'About',
10-
'link': '#'
11-
}, {
12-
'title': 'Contact',
13-
'link': '#'
14-
}];
15-
<% if(mongo && mongoPassportUser) { %>
8+
}<% if(mongoPassportUser) { %>, {
9+
'title': 'Settings',
10+
'link': '/settings'
11+
}<% } %>];
12+
<% if(mongoPassportUser) { %>
1613
$scope.logout = function() {
1714
Auth.logout()
1815
.then(function() {

templates/javascript/controllers/signup.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ angular.module('<%= scriptAppName %>')
1515
password: $scope.user.password
1616
})
1717
.then( function(user) {
18-
// Success, redirect to home
18+
// Account created, redirect to home
1919
$location.path('/');
2020
})
2121
.catch( function(err) {
2222
var err = err.data;
2323
$scope.errors = {};
2424

25-
// Update validity form fields that match the error fields
25+
// Update validity of form fields that match the mongoose errors
2626
angular.forEach(err.errors, function(error, field) {
2727
form[field].$setValidity('mongoose', false);
2828
$scope.errors[field] = error.type;

0 commit comments

Comments
 (0)