update password flow logout method

pull/7861/head
mehmet-erim 5 years ago
parent b204b6e63a
commit 0e0af1e872

@ -11,9 +11,9 @@ import { ManageProfileComponent } from './components/manage-profile/manage-profi
import { PersonalSettingsComponent } from './components/personal-settings/personal-settings.component';
import { RegisterComponent } from './components/register/register.component';
import { TenantBoxComponent } from './components/tenant-box/tenant-box.component';
import { Options } from './models/options';
import { ACCOUNT_OPTIONS } from './tokens/options.token';
import { accountOptionsFactory } from './utils/factory-utils';
import { AccountConfigOptions } from './models/config-options';
import { ACCOUNT_CONFIG_OPTIONS } from './tokens/config-options.token';
import { accountConfigOptionsFactory } from './utils/factory-utils';
import { AuthenticationFlowGuard } from './guards/authentication-flow.guard';
import { AuthenticationService } from './services/authentication.service';
import { ForgotPasswordComponent } from './components/forgot-password/forgot-password.component';
@ -43,23 +43,23 @@ const declarations = [
exports: [...declarations],
})
export class AccountModule {
static forChild(options = {} as Options): ModuleWithProviders<AccountModule> {
static forChild(options = {} as AccountConfigOptions): ModuleWithProviders<AccountModule> {
return {
ngModule: AccountModule,
providers: [
AuthenticationFlowGuard,
AuthenticationService,
{ provide: ACCOUNT_OPTIONS, useValue: options },
{ provide: ACCOUNT_CONFIG_OPTIONS, useValue: options },
{
provide: 'ACCOUNT_OPTIONS',
useFactory: accountOptionsFactory,
deps: [ACCOUNT_OPTIONS],
useFactory: accountConfigOptionsFactory,
deps: [ACCOUNT_CONFIG_OPTIONS],
},
],
};
}
static forLazy(options = {} as Options): NgModuleFactory<AccountModule> {
static forLazy(options = {} as AccountConfigOptions): NgModuleFactory<AccountModule> {
return new LazyModuleFactory(AccountModule.forChild(options));
}
}

@ -11,8 +11,8 @@ import { from, Observable } from 'rxjs';
import { OAuthService } from 'angular-oauth2-oidc';
import { HttpHeaders } from '@angular/common/http';
import { switchMap, take, tap } from 'rxjs/operators';
import { ACCOUNT_OPTIONS } from '../tokens/options.token';
import { Options } from '../models/options';
import { ACCOUNT_CONFIG_OPTIONS } from '../tokens/config-options.token';
import { AccountConfigOptions } from '../models/config-options';
import snq from 'snq';
import { Router } from '@angular/router';
@ -25,7 +25,7 @@ export class AuthenticationService {
protected oAuthService: OAuthService,
protected appConfigService: AbpApplicationConfigurationService,
protected configState: ConfigStateService,
@Inject(ACCOUNT_OPTIONS) protected options: Options,
@Inject(ACCOUNT_CONFIG_OPTIONS) protected options: AccountConfigOptions,
protected router: Router,
) {}

@ -1,6 +1,6 @@
import { Options } from '../models/options';
import { AccountConfigOptions } from '../models/config-options';
export function accountOptionsFactory(options: Options) {
export function accountConfigOptionsFactory(options: AccountConfigOptions) {
return {
redirectUrl: '/',
...options,

@ -110,23 +110,13 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy {
}
logout() {
const rest = this.injector.get(RestService);
const issuer = this.configState.getDeep('environment.oAuthConfig.issuer');
return rest
.request(
{
method: 'GET',
url: '/api/account/logout',
},
null,
issuer,
)
.pipe(
switchMap(() => from(this.oAuthService.revokeTokenAndLogout())),
switchMap(() => this.appConfigService.get()),
tap(res => this.configState.setState(res)),
);
const router = this.injector.get(Router);
return from(this.oAuthService.revokeTokenAndLogout()).pipe(
switchMap(() => this.appConfigService.get()),
tap(res => this.configState.setState(res)),
tap(() => router.navigateByUrl('/')),
);
}
destroy() {}

Loading…
Cancel
Save