Skip to content

Commit b61c2cc

Browse files
committed
AccountManagement single page
account management is working single page
1 parent b9542e2 commit b61c2cc

File tree

8 files changed

+95
-100
lines changed

8 files changed

+95
-100
lines changed

Diff for: Zenergy/Zenergy/Pages/accountManagement.html

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+

2+
<h2>My account</h2>
3+
4+
<div class="container " ng-controller="accountManagementPageController">
5+
<div class="row">
6+
<div name="formInformation" class="col-md-3 col-lg-offset-4">
7+
<h1>Change informations</h1>
8+
<form ng-submit="changeInformations()">
9+
<!--
10+
<div class="form-group">
11+
<input type="email" class="form-control" ng-model="user.mail" placeholder="Email"required>{{user.mail}}</input>
12+
</div>
13+
-->
14+
<div class="form-group">
15+
<input type="text" class="form-control" ng-model="user.firstName" placeholder="Firstname" value="{{user.firstname}}">
16+
</div>
17+
18+
<div class="form-group">
19+
<input type="text" class="form-control" ng-model="user.lastName" placeholder="Lastname">{{user.Lastname}}</input>
20+
</div>
21+
22+
<div class="form-group">
23+
<input type="text" class="form-control" ng-model="user.adr1" placeholder="Address">{{user.adr1}}</input>
24+
</div>
25+
26+
<div class="form-group">
27+
<input type="text" class="form-control" ng-model="user.adr2" placeholder="Rest of the address ">{{user.adr2}}</input>
28+
</div>
29+
30+
<div class="form-group">
31+
<input type="text" class="form-control" ng-model="user.pc" placeholder="Postal Code ">{{user.pc}}</input>
32+
</div>
33+
34+
<div class="form-group">
35+
<input type="text" class="form-control" ng-model="user.town" placeholder="Town ">{{user.town}}</input>
36+
</div>
37+
38+
<div class="form-group">
39+
<input type="text" class="form-control" ng-model="user.phone" placeholder="Phone ">{{user.phone}}</input>
40+
</div>
41+
42+
<button type="button" id="cancel" class="btn btn-danger">Cancel</button>
43+
<input type="submit" id="submit" value="Apply changes" class="btn btn-primary" />
44+
</form>
45+
</div>
46+
<div name="changePassword" class="col-md-3 col-lg-offset-4">
47+
<h1>Change password</h1>
48+
<form ng-submit="changePassword()">
49+
<div class="form-group">
50+
<input type="password" id="password" class="form-control" ng-model="user.password" placeholder="Password" required>{{user.password}}</input>
51+
</div>
52+
<div class="form-group">
53+
<input type="password" id="passwordBis" class="form-control" ng-model="user.passwordBis" placeholder="Confirm Password" required samepassword="password">
54+
</div>
55+
<p class="text-danger" ng-if="passNotMatch">Passwords don't match</p>
56+
<input type="submit" id="submit" value="Change password" class="btn btn-primary" />
57+
58+
</form>
59+
60+
<br />
61+
<button type="button" id="submit" class="btn btn-success btn-lg">Become Member</button>
62+
</div>
63+
</div>
64+
</div>
65+

Diff for: Zenergy/Zenergy/Providers/ApplicationOAuthProvider.cs

+1-25
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,6 @@ public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwner
5151
identity.AddClaim(new Claim("mail", context.UserName));
5252
identity.AddClaim(new Claim("role", "user"));
5353
identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName));
54-
//identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.userId.ToString()));
55-
identity.AddClaim(new Claim("UserId", user.userId.ToString()));
56-
57-
//identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.userId.ToString()));
58-
identity.AddClaim(new Claim("UserId", user.userId.ToString()));
59-
60-
if (user.member != null)
61-
{
62-
identity.AddClaim(new Claim(ClaimTypes.Role, "Member"));
63-
}
64-
if (user.contributor != null)
65-
{
66-
identity.AddClaim(new Claim(ClaimTypes.Role, "Contributor"));
67-
}
68-
if (user.manager != null)
69-
{
70-
identity.AddClaim(new Claim(ClaimTypes.Role, "Manager"));
71-
}
72-
if (user.admin != null)
73-
{
74-
identity.AddClaim(new Claim(ClaimTypes.Role, "Admin"));
75-
}
76-
77-
//identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.userId.ToString()));
7854
identity.AddClaim(new Claim("UserId", user.userId.ToString()));
7955

8056
if (user.member != null)
@@ -92,7 +68,7 @@ public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwner
9268
if (user.admin != null)
9369
{
9470
identity.AddClaim(new Claim(ClaimTypes.Role, "Admin"));
95-
}
71+
}
9672

9773
AuthenticationProperties properties = CreateProperties(user.userId.ToString(), user.mail);
9874
AuthenticationTicket ticket = new AuthenticationTicket(identity, properties);

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

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,35 @@
1-
zenergyApp.controller("accountManagementPageController", ["$scope", "$http", "$window", function ($scope, $http, $window) {
1+
zenergyApp.controller("accountManagementPageController", ["$scope", "$http", "tokenService", "$window", function ($scope, $http, $window) {
2+
3+
console.log(tokenService.userId);
4+
5+
/* var response = $http({
6+
url: '/api/users/',
7+
method: 'GET',
8+
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 },
9+
headers: {
10+
'Content-Type': 'application/json'
11+
}
12+
}).then(function successCallback(response) {
13+
$scope.hasError = false;
14+
window.location.replace("/home"); // $location.path("/#");
15+
}, function errorCallback(response) {
16+
$scope.hasError = true;
17+
$scope.user.mail = '';
18+
$scope.user.password = '';
19+
});*/
220

321
$scope.user = { mail: '', password: '', passwordBis: '', lastName: '', firstName: '', adr1: '', adr2: '', pc: '', town: '', phone: '' };
422
$scope.hasError = false;
523
$scope.passNotMatch = false;
624

25+
26+
727
$scope.changeInformations = function () {
828

929
if (!$scope.hasError) {
1030
var response = $http({
1131
url: '/api/Account/update',
12-
method: 'POST',
32+
method: 'PUT',
1333
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 },
1434
headers: {
1535
'Content-Type': 'application/json'

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}).then(function successCallback(response) {
1515
$scope.hasError = false;
1616
console.log(response);
17-
tokenService.saveToken(response.data.access_token, response.data.userName);
17+
tokenService.saveToken(response.data.access_token, response.data.userName, response.data.userId);
1818
$location.path('/');
1919
}, function errorCallback(response) {
2020
$scope.hasError = true;

Diff for: Zenergy/Zenergy/Scripts/Lib/_references.js

286 Bytes
Binary file not shown.

Diff for: Zenergy/Zenergy/Scripts/zenergyApp.js

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ zenergyApp.config(function ($routeProvider) {
2323
templateUrl: 'Pages/register.html',
2424
controller: 'registerPageController'
2525
})
26+
27+
.when('/Account', {
28+
templateUrl: 'Pages/accountManagement.html',
29+
controller: 'accountManagementPageController'
30+
})
2631
});
2732

2833

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

-70
This file was deleted.

Diff for: Zenergy/Zenergy/Zenergy.csproj

+1-2
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,9 @@
304304
<Content Include="favicon.ico" />
305305
<Content Include="fonts\glyphicons-halflings-regular.svg" />
306306
<Content Include="Global.asax" />
307+
<Content Include="Pages\accountManagement.html" />
307308
<Content Include="Pages\profile.html" />
308309
<Content Include="Scripts\Controllers\accountManagementPageController.js" />
309-
<Content Include="Scripts\Controllers\accountManagementPageController.js" />
310310
<Content Include="Scripts\Controllers\homePageController.js" />
311311
<Content Include="Scripts\Controllers\loginPageController.js" />
312312
<Content Include="Scripts\Controllers\mainController.js" />
@@ -1164,7 +1164,6 @@
11641164
<Content Include="Pages\login.html" />
11651165
<Content Include="Views\Shared\_Layout.cshtml" />
11661166
<Content Include="Pages\register.html" />
1167-
<Content Include="Views\AccountManagement\index.cshtml" />
11681167
</ItemGroup>
11691168
<ItemGroup>
11701169
<Folder Include="App_Data\" />

0 commit comments

Comments
 (0)