Skip to content

Commit 454111f

Browse files
committed
changes on the account management interface
1 parent 51a8066 commit 454111f

File tree

3 files changed

+45
-29
lines changed

3 files changed

+45
-29
lines changed

Diff for: Zenergy/Zenergy/Controllers/ApiControllers/usersController.cs

-12
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,6 @@ public async Task<IHttpActionResult> Getuser(int id)
4545
return Ok(user);
4646
}
4747

48-
[Route("api/users/findByMail")]
49-
[HttpGet]
50-
[ResponseType(typeof(user))]
51-
public async Task<IHttpActionResult> findByMail(string userMail)
52-
{
53-
user user = await userServices.findByMail(userMail);
54-
if (user == null)
55-
{
56-
return NotFound();
57-
}
58-
return Ok(user);
59-
}
6048

6149
// GET: api/users/findByRole
6250
// Return all the users of a role

Diff for: Zenergy/Zenergy/Scripts/Controllers/accountManagementPageController.js

+21
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@
66

77
$scope.changeInformations = function () {
88

9+
if (!$scope.hasError) {
10+
var response = $http({
11+
url: '/api/Account/update',
12+
method: 'POST',
13+
data: { userId: 1, password: CryptoJS.MD5($scope.user.password).toString(), lastName: $scope.user.lastName, firstName: $scope.user.firstName, adr1: $scope.user.adr1, adr2: $scope.user.adr2, pc: $scope.user.pc, town: $scope.user.town, mail: $scope.user.mail, phone: $scope.user.phone },
14+
headers: {
15+
'Content-Type': 'application/json'
16+
}
17+
}).then(function successCallback(response) {
18+
$scope.hasError = false;
19+
window.location.replace("/home");
20+
}, function errorCallback(response) {
21+
$scope.hasError = true;
22+
$scope.user.mail = '';
23+
$scope.user.password = '';
24+
});
25+
}
26+
};
27+
28+
$scope.changePassword = function () {
29+
930
if ($scope.user.password != $scope.user.passwordBis) {
1031
$scope.hasError = true;
1132
$scope.passNotMatch = true;

Diff for: Zenergy/Zenergy/Views/AccountManagement/index.cshtml

+24-17
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,13 @@
88
<div class="container " ng-controller="accountManagementPageController">
99
<div class="row">
1010
<div name="formInformation" class="col-md-3 col-lg-offset-4">
11-
<h1>Register</h1>
11+
<h1>Change informations</h1>
1212
<form ng-submit="changeInformations()">
1313
<!--
14-
<div class="form-group">
15-
<input type="email" class="form-control" ng-model="user.mail" placeholder="Email"required>{{user.mail}}</input>
16-
</div>
17-
-->
18-
19-
<div class="form-group">
20-
<input type="password" id="password" class="form-control" ng-model="user.password" placeholder="Password" required>{{user.password}}</input>
21-
</div>
22-
23-
<div class="form-group">
24-
<input type="password" id="passwordBis" class="form-control" ng-model="user.passwordBis" placeholder="Confirm Password" required samepassword="password">
25-
</div>
26-
<p class="text-danger" ng-if="passNotMatch">Passwords don't match</p>
27-
14+
<div class="form-group">
15+
<input type="email" class="form-control" ng-model="user.mail" placeholder="Email"required>{{user.mail}}</input>
16+
</div>
17+
-->
2818
<div class="form-group">
2919
<input type="text" class="form-control" ng-model="user.firstName" placeholder="Firstname">{{user.firstname}}</input>
3020
</div>
@@ -53,11 +43,28 @@
5343
<input type="text" class="form-control" ng-model="user.phone" placeholder="Phone ">{{user.phone}}</input>
5444
</div>
5545

56-
<button type="button" id="cancel" value="Cancel" class="btn btn-danger" />
46+
<button type="button" id="cancel" class="btn btn-danger">Cancel</button>
5747
<input type="submit" id="submit" value="Apply changes" class="btn btn-primary" />
5848
</form>
59-
<button type="button" id="submit" value="Become Member" class="btn btn-success btn-lg" />
49+
</div>
50+
<div name="changePassword" class="col-md-3 col-lg-offset-4">
51+
<h1>Change password</h1>
52+
<form ng-submit="changePassword()">
53+
<div class="form-group">
54+
<input type="password" id="password" class="form-control" ng-model="user.password" placeholder="Password" required>{{user.password}}</input>
55+
</div>
56+
<div class="form-group">
57+
<input type="password" id="passwordBis" class="form-control" ng-model="user.passwordBis" placeholder="Confirm Password" required samepassword="password">
58+
</div>
59+
<p class="text-danger" ng-if="passNotMatch">Passwords don't match</p>
60+
<input type="submit" id="submit" value="Change password" class="btn btn-primary" />
61+
62+
</form>
63+
64+
<br />
65+
<button type="button" id="submit" class="btn btn-success btn-lg">Become Member</button>
6066
</div>
6167
</div>
6268
</div>
6369

70+

0 commit comments

Comments
 (0)