Skip to content

Commit da7c11b

Browse files
stherrienaspnetAwk34
authored andcommitted
chore(client): upgade angular
1 parent 0ca2a33 commit da7c11b

File tree

4 files changed

+42
-38
lines changed

4 files changed

+42
-38
lines changed

Diff for: templates/app/_package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@
5454
"@angularclass/match-control": "^2.0.0",
5555
"reflect-metadata": "^0.1.3",
5656
"rxjs": "^5.3.0",
57-
"zone.js": "^0.7.2",
58-
"@angular/common": "~2.4.9",
59-
"@angular/compiler": "~2.4.9",
60-
"@angular/core": "~2.4.9",
61-
"@angular/forms": "~2.4.9",
62-
"@angular/http": "~2.4.9",
57+
"zone.js": "^0.8.4",
58+
"@angular/common": "^4.3.3",
59+
"@angular/compiler": "^4.3.3",
60+
"@angular/core": "^4.3.3",
61+
"@angular/forms": "^4.3.3",
62+
"@angular/http": "^4.3.3",
63+
"@angular/platform-browser": "^4.3.3",
64+
"@angular/platform-browser-dynamic": "^4.3.3",
65+
"@angular/router": "^4.3.3",
6366
<%#"@angular/material": "^2.0.0-alpha.10",%>
64-
"@angular/platform-browser": "~2.4.9",
65-
"@angular/platform-browser-dynamic": "~2.4.9",
66-
"@angular/router": "^3.4.7",
6767
"@angularclass/hmr": "^1.2.1",
6868
<%_ if(filters.ts) { -%>
6969
"@types/core-js": "^0.9.41",
@@ -82,7 +82,7 @@
8282
"@types/webpack": "^2.2.15",
8383
<%_ } -%>
8484
"angular2-universal": "2.1.0-rc.1",
85-
"angular2-jwt": "^0.1.24",
85+
"angular2-jwt": "^0.1.28",
8686
<% if(filters.auth) { %>
8787
"angular-validation-match": "^1.9.0",<% } %>
8888
<% if(filters.uirouter) { %>

Diff for: templates/app/client/app/account(auth)/settings/settings.component.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,14 @@ export class SettingsComponent {
4040
changePassword(form) {
4141
this.submitted = true;
4242

43-
if(form.$valid) {
44-
this.AuthService.changePassword(this.user.oldPassword, this.user.newPassword)
45-
.then(() => {
46-
this.message = 'Password successfully changed.';
47-
})
48-
.catch(() => {
49-
form.password.$setValidity('mongoose', false);
50-
this.errors.other = 'Incorrect password';
51-
this.message = '';
52-
});
53-
}
43+
return this.AuthService.changePassword(this.user.oldPassword, this.user.newPassword)
44+
.then(() => {
45+
this.message = 'Password successfully changed.';
46+
})
47+
.catch(() => {
48+
// form.password.$setValidity('mongoose', false);
49+
this.errors.other = 'Incorrect password';
50+
this.message = '';
51+
});
5452
}
5553
}

Diff for: templates/app/client/app/account(auth)/settings/settings.html

+9-11
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,31 @@ <h1>Change Password</h1>
99
<div class="form-group">
1010
<label>Current Password</label>
1111

12-
<input type="password" name="password" class="form-control" [(ngModel)]="user.oldPassword" mongoose-error/>
13-
<p class="help-block" [hidden]="!form.password.$error.mongoose">
14-
{{ errors.other }}
12+
<input type="password" name="password" class="form-control" [(ngModel)]="user.oldPassword" required #oldPassword="ngModel"/>
13+
<p class="help-block" [hidden]="oldPassword.valid || !submitted">
14+
Required
1515
</p>
1616
</div>
1717

1818
<div class="form-group">
1919
<label>New Password</label>
2020

21-
<input type="password" name="newPassword" class="form-control" [(ngModel)]="user.newPassword"
22-
ng-minlength="3"
23-
required/>
21+
<input type="password" name="newPassword" class="form-control" [(ngModel)]="user.newPassword" required #newPassword="ngModel"
22+
minlength="3"/>
2423
<p class="help-block"
25-
[hidden]="!(form.newPassword.$error.minlength || form.newPassword.$error.required) || !(form.newPassword.$dirty || submitted)">
24+
[hidden]="newPassword.valid || !submitted">
2625
Password must be at least 3 characters.
2726
</p>
2827
</div>
2928

3029
<div class="form-group">
3130
<label>Confirm New Password</label>
3231

33-
<input type="password" name="confirmPassword" class="form-control" [(ngModel)]="user.confirmPassword"
32+
<input type="password" name="confirmPassword" class="form-control" [(ngModel)]="user.confirmPassword" required #confirmPassword="ngModel"
3433
match="user.newPassword"
35-
ng-minlength="3"
36-
required=""/>
34+
minlength="3"/>
3735
<p class="help-block"
38-
[hidden]="!form.confirmPassword.$error.match || !submitted">
36+
[hidden]="confirmPassword.valid || !submitted">
3937
Passwords must match.
4038
</p>
4139

Diff for: templates/app/client/app/app.module.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from '@angular/core';
88
import { BrowserModule } from '@angular/platform-browser';
99
import {
10+
Http,
1011
HttpModule,
1112
BaseRequestOptions,
1213
RequestOptions,
@@ -21,7 +22,7 @@ import {
2122
import { UIRouterModule } from 'ui-router-ng2';<% } %>
2223
<%_ if (filters.ngroute) { -%>
2324
import { RouterModule, Routes } from '@angular/router';<% } %>
24-
import { provideAuth } from 'angular2-jwt';
25+
import { provideAuth, AuthHttp, AuthConfig } from 'angular2-jwt';
2526

2627
import { AppComponent } from './app.component';
2728
import { MainModule } from './main/main.module';
@@ -32,12 +33,19 @@ import { AdminModule } from './admin/admin.module';
3233

3334
import constants from './app.constants';
3435

35-
let providers: Provider[] = [
36-
provideAuth({
37-
// Allow using AuthHttp while not logged in
36+
export function getAuthHttp(http) {
37+
return new AuthHttp(new AuthConfig({
3838
noJwtError: true,
39-
})
40-
];
39+
globalHeaders: [{'Accept': 'application/json'}],
40+
tokenGetter: (() => localStorage.getItem('id_token')),
41+
}), http);
42+
}
43+
44+
let providers: Provider[] = [{
45+
provide: AuthHttp,
46+
useFactory: getAuthHttp,
47+
deps: [Http]
48+
}];
4149

4250
if(constants.env === 'development') {
4351
@Injectable()

0 commit comments

Comments
 (0)