SUPPORT-8956: delete auth-components
This commit is contained in:
parent
4b8dce7f30
commit
c52a094e96
9 changed files with 8 additions and 413 deletions
|
|
@ -1,70 +1,38 @@
|
|||
import {NgModule} from "@angular/core";
|
||||
import {RouterModule, Routes} from "@angular/router";
|
||||
import {AccessDeniedComponent} from "./component/access-denied.component";
|
||||
import {LoginComponent} from "./component/login.component";
|
||||
import {AuthenticationGuard, ConfirmExitGuard, SignedInGuard} from "@webbpm/base-package";
|
||||
import {RegisterComponent} from "./component/register.component";
|
||||
import {ConfirmUserEmailComponent} from "./component/confirm-user-email.component";
|
||||
import {ResetPasswordComponent} from "./component/reset-password.component";
|
||||
import {NewPasswordComponent} from "./component/new-password.component";
|
||||
import {ConfirmExitGuard} from "@webbpm/base-package";
|
||||
|
||||
|
||||
const appRoutes: Routes = [
|
||||
{
|
||||
path: 'login',
|
||||
component: LoginComponent,
|
||||
canActivate: [SignedInGuard]
|
||||
},
|
||||
{
|
||||
path: 'home',
|
||||
loadChildren: 'generated-sources/page-home.module#PagehomeModule',
|
||||
canActivate: [AuthenticationGuard, ConfirmExitGuard]
|
||||
canActivate: [ConfirmExitGuard]
|
||||
},
|
||||
{
|
||||
path: 'app_list',
|
||||
loadChildren: 'generated-sources/page-app_list.module#Pageapp_listModule',
|
||||
canActivate: [AuthenticationGuard, ConfirmExitGuard]
|
||||
canActivate: [ConfirmExitGuard]
|
||||
},
|
||||
{
|
||||
path: 'add_user_application',
|
||||
loadChildren: 'generated-sources/page-add_user_application.module#Pageadd_user_applicationModule',
|
||||
canActivate: [AuthenticationGuard, ConfirmExitGuard]
|
||||
canActivate: [ConfirmExitGuard]
|
||||
},
|
||||
{
|
||||
path: 'edit_user_application',
|
||||
loadChildren: 'generated-sources/page-edit_user_application.module#Pageedit_user_applicationModule',
|
||||
canActivate: [AuthenticationGuard, ConfirmExitGuard]
|
||||
canActivate: [ConfirmExitGuard]
|
||||
},
|
||||
{
|
||||
path: 'block_user_application',
|
||||
loadChildren: 'generated-sources/page-block_user_application.module#Pageblock_user_applicationModule',
|
||||
canActivate: [AuthenticationGuard, ConfirmExitGuard]
|
||||
canActivate: [ConfirmExitGuard]
|
||||
},
|
||||
{
|
||||
path: 'process_application/:id',
|
||||
loadChildren: 'generated-sources/page-process_application.module#Pageprocess_applicationModule',
|
||||
canActivate: [AuthenticationGuard, ConfirmExitGuard]
|
||||
},
|
||||
{
|
||||
path: 'access-denied',
|
||||
component: AccessDeniedComponent,
|
||||
canActivate: [AuthenticationGuard, ConfirmExitGuard]
|
||||
},
|
||||
{
|
||||
path: 'registration',
|
||||
component: RegisterComponent,
|
||||
canActivate: [SignedInGuard]
|
||||
},
|
||||
{
|
||||
path: 'confirm',
|
||||
component: ConfirmUserEmailComponent
|
||||
},
|
||||
{
|
||||
path: 'reset-password',
|
||||
component: ResetPasswordComponent
|
||||
},
|
||||
{
|
||||
path: 'new-password',
|
||||
component: NewPasswordComponent
|
||||
canActivate: [ConfirmExitGuard]
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -11,19 +11,12 @@ import {
|
|||
ProgressIndicationService,
|
||||
SecurityModule
|
||||
} from "@webbpm/base-package";
|
||||
import {AdminMenuComponent} from "./component/admin-menu.component";
|
||||
import {AppHeaderComponent} from "./component/app-header.component";
|
||||
import {AppFooterComponent} from "./component/app-footer.component";
|
||||
import {LogOutComponent} from "./component/logout.component";
|
||||
import {LoginComponent} from "./component/login.component";
|
||||
import {AccessDeniedComponent} from "./component/access-denied.component";
|
||||
import {ApplicationVersionComponent} from "./component/application-version.component";
|
||||
import {RouterModule} from "@angular/router";
|
||||
import {RegisterComponent} from "./component/register.component";
|
||||
import {ConfirmUserEmailComponent} from "./component/confirm-user-email.component";
|
||||
import {InternationalPhoneNumberModule} from "ngx-international-phone-number";
|
||||
import {ResetPasswordComponent} from "./component/reset-password.component";
|
||||
import {NewPasswordComponent} from "./component/new-password.component";
|
||||
import {AppProgressIndicationComponent} from "./component/app-progress-indication.component";
|
||||
import {AppProgressIndicationService} from "./service/app-progress-indication.service";
|
||||
import {VBoxLoadValues} from "../../account_applications/component/container/VBoxLoadValues";
|
||||
|
|
@ -33,15 +26,8 @@ registerLocaleData(localeRu);
|
|||
export const DIRECTIVES = [
|
||||
forwardRef(() => AppHeaderComponent),
|
||||
forwardRef(() => AppFooterComponent),
|
||||
forwardRef(() => AdminMenuComponent),
|
||||
forwardRef(() => ApplicationVersionComponent),
|
||||
forwardRef(() => LogOutComponent),
|
||||
forwardRef(() => LoginComponent),
|
||||
forwardRef(() => AccessDeniedComponent),
|
||||
forwardRef(() => RegisterComponent),
|
||||
forwardRef(() => ConfirmUserEmailComponent),
|
||||
forwardRef(() => ResetPasswordComponent),
|
||||
forwardRef(() => NewPasswordComponent),
|
||||
forwardRef(() => AppProgressIndicationComponent),
|
||||
forwardRef(() => VBoxLoadValues),
|
||||
forwardRef(() => ErvuAccountTextFieldGridEditor)
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
import {ChangeDetectionStrategy, Component, Input} from "@angular/core";
|
||||
import {UserService, Session} from "@webbpm/base-package";
|
||||
import {NgbDropdownConfig, Placement} from "@ng-bootstrap/ng-bootstrap";
|
||||
import {Observable} from "rxjs";
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'admin-menu',
|
||||
templateUrl: '../../../../../src/resources/template/app/component/admin_menu.html',
|
||||
providers: [NgbDropdownConfig],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class AdminMenuComponent {
|
||||
|
||||
@Input()
|
||||
public placement: Placement = 'bottom';
|
||||
public currentSession: Observable<Session>;
|
||||
|
||||
constructor(protected userService: UserService, public config: NgbDropdownConfig) {
|
||||
this.config.placement = this.placement;
|
||||
this.currentSession = this.userService.getCurrentSession();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
import {ActivatedRoute, Router} from "@angular/router";
|
||||
import {ChangeDetectionStrategy, ChangeDetectorRef, Component, Input} from "@angular/core";
|
||||
import {Session, UserService} from "@webbpm/base-package";
|
||||
import {Observable} from "rxjs";
|
||||
|
||||
enum VerificationStatus {
|
||||
VERIFYING = "VERIFYING",
|
||||
VERIFIED = "VERIFIED",
|
||||
FAILED = "FAILED"
|
||||
}
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: "confirm",
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
templateUrl: "../../../../../src/resources/template/app/component/confirm-user-email.html"
|
||||
})
|
||||
export class ConfirmUserEmailComponent {
|
||||
public verificationStatus = VerificationStatus.VERIFYING;
|
||||
public currentSession: Observable<Session>;
|
||||
|
||||
@Input()
|
||||
public errorMessage: string;
|
||||
|
||||
constructor(private router: Router, private userService: UserService,
|
||||
private route: ActivatedRoute, private cd: ChangeDetectorRef) {
|
||||
this.currentSession = this.userService.getCurrentSession();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
const link: string = this.route.snapshot.queryParamMap.get("link");
|
||||
// remove link from url to prevent http referer leakage
|
||||
this.router.navigate([], { relativeTo: this.route, replaceUrl: true });
|
||||
this.userService.confirm(
|
||||
link,
|
||||
(reason) => {
|
||||
this.verificationStatus = VerificationStatus.FAILED;
|
||||
if (reason.status === 404) {
|
||||
this.errorMessage = 'Ссылка недействительна. Требуется повторная регистрация.';
|
||||
}
|
||||
else {
|
||||
this.errorMessage = 'Произошла ошибка, обратитесь в службу технической поддержки!';
|
||||
}
|
||||
this.cd.markForCheck();
|
||||
})
|
||||
.then(() => {
|
||||
this.verificationStatus = VerificationStatus.VERIFIED;
|
||||
this.cd.markForCheck();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
import {Component, Input} from "@angular/core";
|
||||
import {ActivatedRoute, Router} from "@angular/router";
|
||||
import {UserService, Credentials} from "@webbpm/base-package";
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: "login",
|
||||
templateUrl: "../../../../../src/resources/template/app/component/login.html"
|
||||
})
|
||||
export class LoginComponent {
|
||||
|
||||
@Input()
|
||||
public username: string;
|
||||
|
||||
@Input()
|
||||
public password: string;
|
||||
public passwordType: boolean;
|
||||
|
||||
@Input()
|
||||
public errorMessage: string;
|
||||
|
||||
@Input()
|
||||
public confirmationSent: boolean;
|
||||
|
||||
constructor(private router: Router, private userService: UserService,
|
||||
private route: ActivatedRoute) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.confirmationSent = this.route.snapshot.queryParamMap.get('confirmationSent') === 'true';
|
||||
this.router.navigate([], { relativeTo: this.route, replaceUrl: true });
|
||||
}
|
||||
|
||||
public login(): void {
|
||||
let credentials: Credentials = new Credentials();
|
||||
credentials.username = this.username;
|
||||
credentials.password = this.password;
|
||||
|
||||
this.userService.login(credentials, "Password")
|
||||
.then(() => this.router.navigateByUrl("/"),
|
||||
(reason: any) => {
|
||||
switch (reason.status) {
|
||||
case 401: {
|
||||
this.errorMessage = "Неправильный логин или пароль";
|
||||
break;
|
||||
}
|
||||
case 404: {
|
||||
this.errorMessage = "Приложение стартует. Пожалуйста, подождите...";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
this.errorMessage =
|
||||
"Произошла неизвестная ошибка, обратитесь в службу технической поддержки!";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public goToRegister(): void {
|
||||
this.router.navigateByUrl("/register");
|
||||
}
|
||||
|
||||
togglePasswordType(): void {
|
||||
this.passwordType = !this.passwordType;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
import {Component} from "@angular/core";
|
||||
import {UserService, Session, AuthenticationMethodService} from "@webbpm/base-package";
|
||||
import {Observable} from "rxjs";
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: "[log-out]",
|
||||
templateUrl: "../../../../../src/resources/template/app/component/log_out.html"
|
||||
})
|
||||
export class LogOutComponent {
|
||||
|
||||
public currentSession: Observable<Session>;
|
||||
|
||||
constructor(private userService: UserService, private authenticationMethodService: AuthenticationMethodService) {
|
||||
this.currentSession = userService.getCurrentSession();
|
||||
}
|
||||
|
||||
public logout(): void {
|
||||
this.userService.logout();
|
||||
}
|
||||
|
||||
public getCurrentUserName(): string {
|
||||
return this.userService.getCurrentUserName();
|
||||
}
|
||||
|
||||
public getFullUserName(): string {
|
||||
return this.userService.getFullUserName();
|
||||
}
|
||||
|
||||
public isLogoutButtonVisible(): boolean {
|
||||
return this.authenticationMethodService.isFormAuth();
|
||||
}
|
||||
|
||||
public getOrgUnitName(): string {
|
||||
return this.userService.getOrgUnitName();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
import {ActivatedRoute, Router} from "@angular/router";
|
||||
import {Component, Input} from "@angular/core";
|
||||
import {Session, UserPasswordResetRequestDto, UserService} from "@webbpm/base-package";
|
||||
import {Observable} from "rxjs";
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: "newPassword",
|
||||
templateUrl: "../../../../../src/resources/template/app/component/new_password.html"
|
||||
})
|
||||
export class NewPasswordComponent {
|
||||
public currentSession: Observable<Session>;
|
||||
|
||||
private token: string;
|
||||
|
||||
@Input()
|
||||
public password: string;
|
||||
public passwordType: boolean;
|
||||
|
||||
@Input()
|
||||
public confirmPassword: string;
|
||||
public confirmPasswordType: boolean;
|
||||
|
||||
@Input()
|
||||
public errorMessage: string;
|
||||
|
||||
constructor(private router: Router, private userService: UserService,
|
||||
private route: ActivatedRoute) {
|
||||
this.currentSession = this.userService.getCurrentSession();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.token = this.route.snapshot.queryParamMap.get("token");
|
||||
|
||||
this.router.navigate([], {relativeTo: this.route, replaceUrl: true});
|
||||
|
||||
if (this.token == undefined || this.token === '') {
|
||||
this.errorMessage = 'Ссылка недействительна. Требуется повторить восстановление пароля.';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public changePassword(): void {
|
||||
let dto: UserPasswordResetRequestDto = new UserPasswordResetRequestDto();
|
||||
dto.password = this.password;
|
||||
dto.passwordConfirm = this.confirmPassword;
|
||||
this.userService.changePassword(dto, this.token)
|
||||
.then(() => this.router.navigateByUrl("/"),
|
||||
() => {
|
||||
this.errorMessage =
|
||||
'Произошла неизвестная ошибка, обратитесь в службу технической поддержки!';
|
||||
});
|
||||
}
|
||||
|
||||
togglePasswordType(): void {
|
||||
this.passwordType = !this.passwordType;
|
||||
}
|
||||
|
||||
toggleConfirmPasswordType(): void {
|
||||
this.confirmPasswordType = !this.confirmPasswordType;
|
||||
}
|
||||
|
||||
validPasswords(): boolean {
|
||||
if (this.password === undefined || this.confirmPassword === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let eq = this.password === this.confirmPassword;
|
||||
if (!eq) {
|
||||
this.errorMessage = 'Введенные пароли не совпадают. Убедитесь, что данные, ' +
|
||||
'введенные в поле "Подтверждение пароля", совпадают с теми, ' +
|
||||
'которые указаны в поле "Пароль".';
|
||||
}
|
||||
else {
|
||||
this.errorMessage = '';
|
||||
}
|
||||
return eq;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
import {Component, Input, ViewChild} from "@angular/core";
|
||||
import {AppConfigService, UserDto, UserService} from "@webbpm/base-package";
|
||||
import {Router} from "@angular/router";
|
||||
import {PhoneNumberComponent} from "ngx-international-phone-number";
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: "register",
|
||||
templateUrl: "../../../../../src/resources/template/app/component/register.html"
|
||||
})
|
||||
export class RegisterComponent {
|
||||
|
||||
public passwordPattern: string;
|
||||
public passwordPatternErrorMessage: string;
|
||||
public errorMessage: string;
|
||||
|
||||
@Input()
|
||||
public username: string;
|
||||
|
||||
@Input()
|
||||
public email: string;
|
||||
@ViewChild(PhoneNumberComponent)
|
||||
public phone: PhoneNumberComponent;
|
||||
public phoneNumber: string;
|
||||
|
||||
public phoneIsTouched: boolean = false;
|
||||
@Input()
|
||||
public password: string;
|
||||
|
||||
public fieldType: boolean;
|
||||
|
||||
@Input()
|
||||
public consent: string;
|
||||
|
||||
constructor(private router: Router, private userService: UserService,private appConfigService: AppConfigService) {
|
||||
this.passwordPattern = appConfigService.getParamValue("password_pattern");
|
||||
this.passwordPatternErrorMessage = appConfigService.getParamValue("password_pattern_error");
|
||||
}
|
||||
|
||||
public register(): void {
|
||||
let user: UserDto = new UserDto();
|
||||
user.username = this.username;
|
||||
user.email = this.email;
|
||||
user.name = this.username;
|
||||
user.phone = this.phone.value;
|
||||
user.password = this.password;
|
||||
|
||||
this.userService.register(user)
|
||||
.then(() => this.router.navigateByUrl("/login?confirmationSent=true"),
|
||||
(reason: any) => {
|
||||
if (reason.status === 409) {
|
||||
this.errorMessage = 'Пользователь с данным почтовым адресом уже существует';
|
||||
}
|
||||
else {
|
||||
this.errorMessage = 'Произошла неизвестная ошибка, обратитесь в службу технической поддержки!';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
toggleFieldType(): void {
|
||||
this.fieldType = !this.fieldType;
|
||||
}
|
||||
|
||||
phoneHasOnlyDialCode(): boolean {
|
||||
return this.phone.phoneNumber.trim() === this.phone.getSelectedCountryDialCode().trim()
|
||||
}
|
||||
|
||||
phoneInputFocusOut(): void {
|
||||
this.phoneIsTouched = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
import {Component, Input} from "@angular/core";
|
||||
import {UserService} from "@webbpm/base-package";
|
||||
import {Router} from "@angular/router";
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: "resetPassword",
|
||||
templateUrl: "../../../../../src/resources/template/app/component/reset_password.html"
|
||||
})
|
||||
export class ResetPasswordComponent {
|
||||
|
||||
@Input()
|
||||
public email: string;
|
||||
|
||||
@Input()
|
||||
public errorMessage: string;
|
||||
|
||||
constructor(private router: Router, private userService: UserService) {
|
||||
}
|
||||
|
||||
resetPassword(): void {
|
||||
|
||||
this.userService.resetPassword(this.email)
|
||||
.then(() => this.router.navigateByUrl("/"),
|
||||
(reason: any) => {
|
||||
this.errorMessage =
|
||||
'Произошла неизвестная ошибка, обратитесь в службу технической поддержки!';
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue