mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Moved isAuthenticated and isLoading to container
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
<ds-loading *ngIf="(loading | async) || (isAuthenticated | async)" class="m-5"></ds-loading>
|
<ds-loading *ngIf="(loading | async) || (isAuthenticated | async)" class="m-5"></ds-loading>
|
||||||
|
<div *ngIf="!(loading | async) && !(isAuthenticated | async)" class="form-login px-4 py-3">
|
||||||
<ng-container *ngFor="let authMethodModel of injectedAuthMethods">
|
<ng-container *ngFor="let authMethodModel of injectedAuthMethods">
|
||||||
<ds-login-container
|
<ds-login-container
|
||||||
[authMethodModel]="authMethodModel"></ds-login-container>
|
[authMethodModel]="authMethodModel"></ds-login-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
</div>
|
||||||
|
@@ -5,6 +5,8 @@ import { select, Store } from '@ngrx/store';
|
|||||||
import { getAuthenticationMethods, isAuthenticated, isAuthenticationLoading } from '../../core/auth/selectors';
|
import { getAuthenticationMethods, isAuthenticated, isAuthenticationLoading } from '../../core/auth/selectors';
|
||||||
import { CoreState } from '../../core/core.reducers';
|
import { CoreState } from '../../core/core.reducers';
|
||||||
import { InjectedAuthMethodModel } from './injectedAuthMethodModel/injectedAuthMethodModel';
|
import { InjectedAuthMethodModel } from './injectedAuthMethodModel/injectedAuthMethodModel';
|
||||||
|
import { filter, takeWhile } from 'rxjs/operators';
|
||||||
|
import { AuthService } from '../../core/auth/auth.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-log-in',
|
selector: 'ds-log-in',
|
||||||
@@ -35,9 +37,17 @@ export class LogInComponent implements OnInit, OnDestroy {
|
|||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
public loading: Observable<boolean>;
|
public loading: Observable<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component state.
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
private alive = true;
|
||||||
|
|
||||||
private subscription: Subscription;
|
private subscription: Subscription;
|
||||||
|
|
||||||
constructor(private store: Store<CoreState>) {
|
constructor(private store: Store<CoreState>,
|
||||||
|
private authService: AuthService,) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@@ -56,10 +66,22 @@ export class LogInComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
// set isAuthenticated
|
// set isAuthenticated
|
||||||
this.isAuthenticated = this.store.pipe(select(isAuthenticated));
|
this.isAuthenticated = this.store.pipe(select(isAuthenticated));
|
||||||
|
|
||||||
|
// subscribe to success
|
||||||
|
this.store.pipe(
|
||||||
|
select(isAuthenticated),
|
||||||
|
takeWhile(() => this.alive),
|
||||||
|
filter((authenticated) => authenticated))
|
||||||
|
.subscribe(() => {
|
||||||
|
this.authService.redirectAfterLoginSuccess(this.isStandalonePage);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.subscription.unsubscribe();
|
this.subscription.unsubscribe();
|
||||||
|
this.alive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<form *ngIf="!(loading | async) && !(isAuthenticated | async)" class="form-login px-4 py-3" (ngSubmit)="submit()"
|
<!--*ngIf="!(loading | async) && !(isAuthenticated | async)" class="form-login px-4 py-3"-->
|
||||||
|
<form (ngSubmit)="submit()"
|
||||||
[formGroup]="form" novalidate>
|
[formGroup]="form" novalidate>
|
||||||
<label for="inputEmail" class="sr-only">{{"login.form.email" | translate}}</label>
|
<label for="inputEmail" class="sr-only">{{"login.form.email" | translate}}</label>
|
||||||
<input id="inputEmail"
|
<input id="inputEmail"
|
||||||
|
@@ -36,7 +36,7 @@ import { InjectedAuthMethodModel } from '../../injectedAuthMethodModel/injectedA
|
|||||||
animations: [fadeOut]
|
animations: [fadeOut]
|
||||||
})
|
})
|
||||||
@renderAuthMethodFor(AuthMethodType.Password)
|
@renderAuthMethodFor(AuthMethodType.Password)
|
||||||
export class LogInPasswordComponent implements OnDestroy, OnInit {
|
export class LogInPasswordComponent implements OnInit {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The error if authentication fails.
|
* The error if authentication fails.
|
||||||
@@ -66,13 +66,15 @@ export class LogInPasswordComponent implements OnDestroy, OnInit {
|
|||||||
* Whether user is authenticated.
|
* Whether user is authenticated.
|
||||||
* @type {Observable<string>}
|
* @type {Observable<string>}
|
||||||
*/
|
*/
|
||||||
public isAuthenticated: Observable<boolean>;
|
/* public isAuthenticated: Observable<boolean>;*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if the authentication is loading.
|
* True if the authentication is loading.
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
public loading: Observable<boolean>;
|
public loading: Observable<boolean>;
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The authentication form.
|
* The authentication form.
|
||||||
@@ -80,11 +82,11 @@ export class LogInPasswordComponent implements OnDestroy, OnInit {
|
|||||||
*/
|
*/
|
||||||
public form: FormGroup;
|
public form: FormGroup;
|
||||||
|
|
||||||
/**
|
/* /!**
|
||||||
* Component state.
|
* Component state.
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*!/
|
||||||
private alive = true;
|
private alive = true;*/
|
||||||
|
|
||||||
@Input() authMethodModel: InjectedAuthMethodModel;
|
@Input() authMethodModel: InjectedAuthMethodModel;
|
||||||
|
|
||||||
@@ -96,7 +98,7 @@ export class LogInPasswordComponent implements OnDestroy, OnInit {
|
|||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
@Inject('authMethodModelProvider') public injectedAuthMethodModel: InjectedAuthMethodModel,
|
@Inject('authMethodModelProvider') public injectedAuthMethodModel: InjectedAuthMethodModel,
|
||||||
private authService: AuthService,
|
/* private authService: AuthService,*/
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
private store: Store<CoreState>
|
private store: Store<CoreState>
|
||||||
) {
|
) {
|
||||||
@@ -109,7 +111,7 @@ export class LogInPasswordComponent implements OnDestroy, OnInit {
|
|||||||
*/
|
*/
|
||||||
public ngOnInit() {
|
public ngOnInit() {
|
||||||
// set isAuthenticated
|
// set isAuthenticated
|
||||||
this.isAuthenticated = this.store.pipe(select(isAuthenticated));
|
/* this.isAuthenticated = this.store.pipe(select(isAuthenticated));*/
|
||||||
|
|
||||||
// set formGroup
|
// set formGroup
|
||||||
this.form = this.formBuilder.group({
|
this.form = this.formBuilder.group({
|
||||||
@@ -135,7 +137,7 @@ export class LogInPasswordComponent implements OnDestroy, OnInit {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
// set loading
|
/* // set loading
|
||||||
this.loading = this.store.pipe(select(isAuthenticationLoading));
|
this.loading = this.store.pipe(select(isAuthenticationLoading));
|
||||||
|
|
||||||
// subscribe to success
|
// subscribe to success
|
||||||
@@ -146,7 +148,7 @@ export class LogInPasswordComponent implements OnDestroy, OnInit {
|
|||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.authService.redirectAfterLoginSuccess(this.authMethodModel.isStandalonePage);
|
this.authService.redirectAfterLoginSuccess(this.authMethodModel.isStandalonePage);
|
||||||
}
|
}
|
||||||
);
|
);*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,9 +156,9 @@ export class LogInPasswordComponent implements OnDestroy, OnInit {
|
|||||||
* Lifecycle hook that is called when a directive, pipe or service is destroyed.
|
* Lifecycle hook that is called when a directive, pipe or service is destroyed.
|
||||||
* @method ngOnDestroy
|
* @method ngOnDestroy
|
||||||
*/
|
*/
|
||||||
public ngOnDestroy() {
|
/* public ngOnDestroy() {
|
||||||
this.alive = false;
|
this.alive = false;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset error or message.
|
* Reset error or message.
|
||||||
|
Reference in New Issue
Block a user