Skip to content

Commit

Permalink
Merge branch 'rel-3.1' of https://github.com/abpframework/abp into re…
Browse files Browse the repository at this point in the history
…l-3.1
  • Loading branch information
erolarkat committed Sep 1, 2020
2 parents 2f611a5 + cf3faf7 commit 5f9d151
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export abstract class AuthFlowStrategy {
constructor(protected injector: Injector) {
this.store = injector.get(Store);
this.oAuthService = injector.get(OAuthService);
this.oAuthConfig = injector.get(Store).selectSnapshot(ConfigState.getDeep('environment.oAuthConfig'));
this.oAuthConfig = this.store.selectSnapshot(ConfigState.getDeep('environment.oAuthConfig'));
}

async init(): Promise<any> {
Expand All @@ -41,7 +41,14 @@ export class AuthCodeFlowStrategy extends AuthFlowStrategy {
return super
.init()
.then(() => this.oAuthService.tryLogin())
.then(() => this.oAuthService.setupAutomaticSilentRefresh());
.then(() => {
if (this.oAuthService.hasValidAccessToken() || !this.oAuthService.getRefreshToken()) {
return Promise.resolve();
}

return this.oAuthService.refreshToken() as Promise<any>;
})
.then(() => this.oAuthService.setupAutomaticSilentRefresh({}, 'access_token'));
}

login() {
Expand Down Expand Up @@ -88,7 +95,7 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy {
)
.pipe(
tap(() => this.oAuthService.logOut()),
switchMap(() => this.store.dispatch(new GetAppConfiguration())),
switchMap(() => this.store.dispatch(new GetAppConfiguration())),
);
}

Expand Down

0 comments on commit 5f9d151

Please sign in to comment.