|
|
@ -1,6 +1,6 @@ |
|
|
import { ConfigState, GetAppConfiguration } from '@abp/ng.core'; |
|
|
import { ConfigState, GetAppConfiguration, ABP } from '@abp/ng.core'; |
|
|
import { ToasterService } from '@abp/ng.theme.shared'; |
|
|
import { ToasterService } from '@abp/ng.theme.shared'; |
|
|
import { Component } from '@angular/core'; |
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; |
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; |
|
|
import { Navigate } from '@ngxs/router-plugin'; |
|
|
import { Navigate } from '@ngxs/router-plugin'; |
|
|
import { Store } from '@ngxs/store'; |
|
|
import { Store } from '@ngxs/store'; |
|
|
@ -10,13 +10,14 @@ import { catchError, finalize, switchMap, take, tap } from 'rxjs/operators'; |
|
|
import snq from 'snq'; |
|
|
import snq from 'snq'; |
|
|
import { RegisterRequest } from '../../models'; |
|
|
import { RegisterRequest } from '../../models'; |
|
|
import { AccountService } from '../../services/account.service'; |
|
|
import { AccountService } from '../../services/account.service'; |
|
|
|
|
|
import { PasswordRules, validatePassword } from '@ngx-validate/core'; |
|
|
const { maxLength, minLength, required, email } = Validators; |
|
|
const { maxLength, minLength, required, email } = Validators; |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
selector: 'abp-register', |
|
|
selector: 'abp-register', |
|
|
templateUrl: './register.component.html', |
|
|
templateUrl: './register.component.html', |
|
|
}) |
|
|
}) |
|
|
export class RegisterComponent { |
|
|
export class RegisterComponent implements OnInit { |
|
|
form: FormGroup; |
|
|
form: FormGroup; |
|
|
|
|
|
|
|
|
inProgress: boolean; |
|
|
inProgress: boolean; |
|
|
@ -30,10 +31,38 @@ export class RegisterComponent { |
|
|
) { |
|
|
) { |
|
|
this.oauthService.configure(this.store.selectSnapshot(ConfigState.getOne('environment')).oAuthConfig); |
|
|
this.oauthService.configure(this.store.selectSnapshot(ConfigState.getOne('environment')).oAuthConfig); |
|
|
this.oauthService.loadDiscoveryDocument(); |
|
|
this.oauthService.loadDiscoveryDocument(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
|
|
const passwordRules: ABP.Dictionary<string> = this.store.selectSnapshot( |
|
|
|
|
|
ConfigState.getSettings('Identity.Password'), |
|
|
|
|
|
); |
|
|
|
|
|
const passwordRulesArr = [] as PasswordRules; |
|
|
|
|
|
let requiredLength = 1; |
|
|
|
|
|
|
|
|
|
|
|
if ((passwordRules['Abp.Identity.Password.RequireDigit'] || '').toLowerCase() === 'true') { |
|
|
|
|
|
passwordRulesArr.push('number'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ((passwordRules['Abp.Identity.Password.RequireLowercase'] || '').toLowerCase() === 'true') { |
|
|
|
|
|
passwordRulesArr.push('small'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ((passwordRules['Abp.Identity.Password.RequireUppercase'] || '').toLowerCase() === 'true') { |
|
|
|
|
|
passwordRulesArr.push('capital'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (+(passwordRules['Abp.Identity.Password.RequiredUniqueChars'] || 0) > 0) { |
|
|
|
|
|
passwordRulesArr.push('special'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (Number.isInteger(+passwordRules['Abp.Identity.Password.RequiredLength'])) { |
|
|
|
|
|
requiredLength = +passwordRules['Abp.Identity.Password.RequiredLength']; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.form = this.fb.group({ |
|
|
this.form = this.fb.group({ |
|
|
username: ['', [required, maxLength(255)]], |
|
|
username: ['', [required, maxLength(255)]], |
|
|
password: ['', [required, maxLength(32)]], |
|
|
password: ['', [required, validatePassword(passwordRulesArr), minLength(requiredLength), maxLength(32)]], |
|
|
email: ['', [required, email]], |
|
|
email: ['', [required, email]], |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|