-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
angular.module('mean.users').controller('SettingsController', ['$scope', '$http', '$location', 'Users', 'Authentication', | ||
function($scope, $http, $location, Users, Authentication) { | ||
$scope.user = Authentication.user; | ||
|
||
//If user is not signed in then redirect back home | ||
if (!$scope.user) $location.path('/'); | ||
|
||
$scope.updateUserProfile = function() { | ||
$scope.success = $scope.error = null; | ||
var user = new Users($scope.user); | ||
|
||
user.$update(function(response) { | ||
$scope.success = true; | ||
Authentication.user = response; | ||
}, function(response) { | ||
$scope.error = response.data.message; | ||
}); | ||
}; | ||
|
||
$scope.changeUserPassword = function() { | ||
$scope.success = $scope.error = null; | ||
|
||
$http.post('/users/password', $scope.passwordDetails).success(function(response) { | ||
// If successful show success message and clear form | ||
$scope.success = true; | ||
$scope.passwordDetails = null; | ||
}).error(function(response) { | ||
$scope.error = response.message; | ||
}); | ||
}; | ||
} | ||
]); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@media (min-width: 992px) { | ||
.nav-users { | ||
position: fixed; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
|
||
//Users service used for users REST endpoint | ||
angular.module('mean.users').factory('Users', ['$resource', | ||
function($resource) { | ||
return $resource('users', {}, { | ||
update: { | ||
method: 'PUT' | ||
} | ||
}); | ||
} | ||
]); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<section class="row" data-ng-controller="SettingsController"> | ||
<h3 class="col-md-12 text-center">Change your password</h3> | ||
<div class="col-xs-offset-2 col-xs-8 col-md-offset-5 col-md-2"> | ||
<form data-ng-submit="changeUserPassword()" class="signin form-horizontal" autocomplete="off"> | ||
<fieldset> | ||
<div class="form-group"> | ||
<label for="currentPassword">Current Password</label> | ||
<input type="password" id="currentPassword" name="currentPassword" class="form-control" data-ng-model="passwordDetails.currentPassword" placeholder="Current Password"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="newPassword">New Password</label> | ||
<input type="password" id="newPassword" name="newPassword" class="form-control" data-ng-model="passwordDetails.newPassword" placeholder="New Password"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="verifyPassword">Verify Password</label> | ||
<input type="password" id="verifyPassword" name="verifyPassword" class="form-control" data-ng-model="passwordDetails.verifyPassword" placeholder="Verify Password"> | ||
</div> | ||
<div class="text-center form-group"> | ||
<button type="submit" class="btn btn-large btn-primary">Save Password</button> | ||
</div> | ||
<div data-ng-show="success" class="text-center text-success"> | ||
<strong>Password Changed Successfully</strong> | ||
</div> | ||
<div data-ng-show="error" class="text-center text-danger"> | ||
<strong>{{error}}</strong> | ||
</div> | ||
</fieldset> | ||
</form> | ||
</div> | ||
</section> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<section class="row" data-ng-controller="SettingsController"> | ||
<h3 class="col-md-12 text-center">Edit your profile</h3> | ||
<div class="col-xs-offset-2 col-xs-8 col-md-offset-5 col-md-2"> | ||
<form data-ng-submit="updateUserProfile()" class="signin form-horizontal" autocomplete="off"> | ||
<fieldset> | ||
<div class="form-group"> | ||
<label for="firstName">First Name</label> | ||
<input type="text" id="firstName" name="firstName" class="form-control" data-ng-model="user.firstName" placeholder="First Name"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="lastName">Last Name</label> | ||
<input type="text" id="lastName" name="lastName" class="form-control" data-ng-model="user.lastName" placeholder="Last Name"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="email">Email</label> | ||
<input type="text" id="email" name="email" class="form-control" data-ng-model="user.email" placeholder="Email"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="username">Username</label> | ||
<input type="text" id="username" name="username" class="form-control" data-ng-model="user.username" placeholder="Username"> | ||
</div> | ||
<div class="text-center form-group"> | ||
<button type="submit" class="btn btn-large btn-primary">Save Profile</button> | ||
</div> | ||
<div data-ng-show="success" class="text-center text-success"> | ||
<strong>Profile Saved Successfully</strong> | ||
</div> | ||
<div data-ng-show="error" class="text-center text-danger"> | ||
<strong>{{error}}</strong> | ||
</div> | ||
</fieldset> | ||
</form> | ||
</div> | ||
</section> |