frontend: Update login component to handle redirect parameters after login
This commit is contained in:
parent
558fba500a
commit
473c7be726
@ -9,6 +9,7 @@ export * from './console/about/about.component';
|
|||||||
export * from './console/overview/overview.component';
|
export * from './console/overview/overview.component';
|
||||||
export * from './console/login/login.component';
|
export * from './console/login/login.component';
|
||||||
export * from './room-creator/room-creator.component';
|
export * from './room-creator/room-creator.component';
|
||||||
|
export * from './login/login.component';
|
||||||
export * from './video-room/video-room.component';
|
export * from './video-room/video-room.component';
|
||||||
export * from './participant-name-form/participant-name-form.component';
|
export * from './participant-name-form/participant-name-form.component';
|
||||||
export * from './disconnected/disconnected.component';
|
export * from './disconnected/disconnected.component';
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { MatButton } from '@angular/material/button';
|
|||||||
import { MatIcon } from '@angular/material/icon';
|
import { MatIcon } from '@angular/material/icon';
|
||||||
import { MatToolbar } from '@angular/material/toolbar';
|
import { MatToolbar } from '@angular/material/toolbar';
|
||||||
import { MatTooltip } from '@angular/material/tooltip';
|
import { MatTooltip } from '@angular/material/tooltip';
|
||||||
import { Router } from '@angular/router';
|
import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import { ContextService, AuthService } from '../../services/index';
|
import { ContextService, AuthService } from '../../services/index';
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
|
|
||||||
@ -26,9 +26,11 @@ export class LoginComponent {
|
|||||||
password: new FormControl('', [Validators.required, Validators.minLength(4)])
|
password: new FormControl('', [Validators.required, Validators.minLength(4)])
|
||||||
});
|
});
|
||||||
loginErrorMessage: string | undefined;
|
loginErrorMessage: string | undefined;
|
||||||
|
redirectTo = ''; // By default, redirect to RoomCreatorComponent
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
|
private route: ActivatedRoute,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private contextService: ContextService
|
private contextService: ContextService
|
||||||
) {}
|
) {}
|
||||||
@ -37,6 +39,11 @@ export class LoginComponent {
|
|||||||
this.version = this.contextService.getVersion();
|
this.version = this.contextService.getVersion();
|
||||||
this.openviduLogoUrl = this.contextService.getOpenViduLogoUrl();
|
this.openviduLogoUrl = this.contextService.getOpenViduLogoUrl();
|
||||||
this.backgroundImageUrl = this.contextService.getBackgroundImageUrl();
|
this.backgroundImageUrl = this.contextService.getBackgroundImageUrl();
|
||||||
|
const redirectParam = this.route.snapshot.queryParams['redirectTo'];
|
||||||
|
|
||||||
|
if (redirectParam) {
|
||||||
|
this.redirectTo = redirectParam;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async login() {
|
async login() {
|
||||||
@ -53,7 +60,7 @@ export class LoginComponent {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.router.navigate(['']);
|
this.router.navigate([this.redirectTo]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if ((error as HttpErrorResponse).status === 429) {
|
if ((error as HttpErrorResponse).status === 429) {
|
||||||
this.loginErrorMessage = 'Too many login attempts. Please try again later';
|
this.loginErrorMessage = 'Too many login attempts. Please try again later';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user