Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Adding New files
Browse files Browse the repository at this point in the history
  • Loading branch information
amoshaviv committed Mar 25, 2014
1 parent 38bffbc commit 7ba7dcf
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 0 deletions.
34 changes: 34 additions & 0 deletions public/modules/users/controllers/settings.js
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;
});
};
}
]);
5 changes: 5 additions & 0 deletions public/modules/users/css/users.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@media (min-width: 992px) {
.nav-users {
position: fixed;
}
}
12 changes: 12 additions & 0 deletions public/modules/users/services/users.js
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'
}
});
}
]);
30 changes: 30 additions & 0 deletions public/modules/users/views/settings/password.html
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>
34 changes: 34 additions & 0 deletions public/modules/users/views/settings/profile.html
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>

0 comments on commit 7ba7dcf

Please sign in to comment.