Merge pull request #9337 from abpframework/feat/v7095

Pass tenantId to reset password
pull/9356/head^2
Mehmet Erim 4 years ago committed by GitHub
commit d30a870b19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,6 +23,9 @@ export const environment = {
url: 'https://localhost:44305', url: 'https://localhost:44305',
rootNamespace: 'MyCompanyName.MyProjectName', rootNamespace: 'MyCompanyName.MyProjectName',
}, },
AbpAccount: {
rootNamespace: 'Volo.Abp',
},
AbpFeatureManagement: { AbpFeatureManagement: {
rootNamespace: 'Volo.Abp', rootNamespace: 'Volo.Abp',
}, },

@ -69,6 +69,7 @@ const routes: Routes = [
component: ReplaceableRouteContainerComponent, component: ReplaceableRouteContainerComponent,
canActivate: [AuthenticationFlowGuard], canActivate: [AuthenticationFlowGuard],
data: { data: {
tenantBoxVisible: false,
replaceableComponent: { replaceableComponent: {
key: eAccountComponents.ResetPassword, key: eAccountComponents.ResetPassword,
defaultComponent: ResetPasswordComponent, defaultComponent: ResetPasswordComponent,

@ -1,6 +1,6 @@
<div class="row"> <div class="row">
<div class="mx-auto col col-md-5"> <div class="mx-auto col col-md-5">
<ng-container *ngIf="(isMultiTenancyEnabled$ | async) && multiTenancy.isTenantBoxVisible"> <ng-container *ngIf="(isMultiTenancyEnabled$ | async) && isTenantBoxVisible">
<abp-tenant-box *abpReplaceableTemplate="{ componentKey: tenantBoxKey }"></abp-tenant-box> <abp-tenant-box *abpReplaceableTemplate="{ componentKey: tenantBoxKey }"></abp-tenant-box>
</ng-container> </ng-container>

@ -1,8 +1,9 @@
import { ConfigStateService, MultiTenancyService, SubscriptionService } from '@abp/ng.core'; import { ConfigStateService, MultiTenancyService, SubscriptionService } from '@abp/ng.core';
import { Component } from '@angular/core'; import { Component, Injector } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { eAccountComponents } from '../../enums/components'; import { eAccountComponents } from '../../enums/components';
import { ActivatedRoute } from '@angular/router';
@Component({ @Component({
selector: 'abp-auth-wrapper', selector: 'abp-auth-wrapper',
@ -20,9 +21,24 @@ export class AuthWrapperComponent {
} }
tenantBoxKey = eAccountComponents.TenantBox; tenantBoxKey = eAccountComponents.TenantBox;
route: ActivatedRoute;
private _tenantBoxVisible = true;
private setTenantBoxVisibility = () => {
this._tenantBoxVisible = this.route.snapshot.firstChild.data.tenantBoxVisible ?? true;
};
get isTenantBoxVisible() {
return this._tenantBoxVisible && this.multiTenancy.isTenantBoxVisible;
}
constructor( constructor(
public readonly multiTenancy: MultiTenancyService, public readonly multiTenancy: MultiTenancyService,
private configState: ConfigStateService, private configState: ConfigStateService,
) {} injector: Injector,
) {
this.route = injector.get(ActivatedRoute);
this.setTenantBoxVisibility();
}
} }

@ -18,6 +18,7 @@ export class ResetPasswordComponent implements OnInit {
inProgress = false; inProgress = false;
isPasswordReset = false; isPasswordReset = false;
tenantId = '';
mapErrorsFn: Validation.MapErrorsFn = (errors, groupErrors, control) => { mapErrorsFn: Validation.MapErrorsFn = (errors, groupErrors, control) => {
if (PASSWORD_FIELDS.indexOf(String(control.name)) < 0) return errors; if (PASSWORD_FIELDS.indexOf(String(control.name)) < 0) return errors;
@ -34,7 +35,8 @@ export class ResetPasswordComponent implements OnInit {
) {} ) {}
ngOnInit(): void { ngOnInit(): void {
this.route.queryParams.subscribe(({ userId, resetToken }) => { this.route.queryParams.subscribe(({ userId, resetToken, tenantId }) => {
this.tenantId = tenantId;
if (!userId || !resetToken) this.router.navigateByUrl('/account/login'); if (!userId || !resetToken) this.router.navigateByUrl('/account/login');
this.form = this.fb.group( this.form = this.fb.group(
@ -61,6 +63,7 @@ export class ResetPasswordComponent implements OnInit {
userId: this.form.get('userId').value, userId: this.form.get('userId').value,
resetToken: this.form.get('resetToken').value, resetToken: this.form.get('resetToken').value,
password: this.form.get('password').value, password: this.form.get('password').value,
tenantId: this.tenantId || undefined, // if this.tenantId is empty, we should not send it at all
}) })
.pipe(finalize(() => (this.inProgress = false))) .pipe(finalize(() => (this.inProgress = false)))
.subscribe(() => { .subscribe(() => {

@ -1,2 +1,4 @@
import * as Web from './web';
export * from './account.service'; export * from './account.service';
export * from './models'; export * from './models';
export { Web };

@ -1,5 +1,6 @@
import type { ExtensibleObject } from '@abp/ng.core';
export interface RegisterDto { export interface RegisterDto extends ExtensibleObject {
userName: string; userName: string;
emailAddress: string; emailAddress: string;
password: string; password: string;
@ -8,6 +9,7 @@ export interface RegisterDto {
export interface ResetPasswordDto { export interface ResetPasswordDto {
userId?: string; userId?: string;
tenantId?: string;
resetToken: string; resetToken: string;
password: string; password: string;
} }

@ -0,0 +1,35 @@
import type { AbpLoginResult, UserLoginInfo } from './models/models';
import { RestService } from '@abp/ng.core';
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root',
})
export class AccountService {
apiName = 'AbpAccount';
checkPasswordByLogin = (login: UserLoginInfo) =>
this.restService.request<any, AbpLoginResult>({
method: 'POST',
url: '/api/account/check-password',
body: login,
},
{ apiName: this.apiName });
loginByLogin = (login: UserLoginInfo) =>
this.restService.request<any, AbpLoginResult>({
method: 'POST',
url: '/api/account/login',
body: login,
},
{ apiName: this.apiName });
logout = () =>
this.restService.request<any, void>({
method: 'GET',
url: '/api/account/logout',
},
{ apiName: this.apiName });
constructor(private restService: RestService) {}
}

@ -0,0 +1,3 @@
import * as Models from './models';
export * from './account.service';
export { Models };

@ -0,0 +1,2 @@
export * from './login-result-type.enum';
export * from './models';

@ -0,0 +1,11 @@
import { mapEnumToOptions } from '@abp/ng.core';
export enum LoginResultType {
Success = 1,
InvalidUserNameOrPassword = 2,
NotAllowed = 3,
LockedOut = 4,
RequiresTwoFactor = 5,
}
export const loginResultTypeOptions = mapEnumToOptions(LoginResultType);

@ -0,0 +1,12 @@
import type { LoginResultType } from './login-result-type.enum';
export interface AbpLoginResult {
result: LoginResultType;
description?: string;
}
export interface UserLoginInfo {
userNameOrEmailAddress: string;
password: string;
rememberMe: boolean;
}

@ -0,0 +1,2 @@
import * as Controllers from './controllers';
export { Controllers };

@ -0,0 +1,2 @@
import * as Account from './account';
export { Account };

@ -0,0 +1,2 @@
import * as Areas from './areas';
export { Areas };
Loading…
Cancel
Save