[3.0] Improved login by params to support nagivation to different dashboards (#2703)
* Improved login by params to support nagivation to different dashboards * Refactorting
This commit is contained in:
parent
8b5793f203
commit
11d4ef74e8
@ -261,6 +261,8 @@ export class AuthService {
|
||||
const publicId = this.utils.getQueryParam('publicId');
|
||||
const accessToken = this.utils.getQueryParam('accessToken');
|
||||
const refreshToken = this.utils.getQueryParam('refreshToken');
|
||||
const username = this.utils.getQueryParam('username');
|
||||
const password = this.utils.getQueryParam('password');
|
||||
if (publicId) {
|
||||
return this.publicLogin(publicId).pipe(
|
||||
mergeMap((response) => {
|
||||
@ -290,6 +292,23 @@ export class AuthService {
|
||||
return throwError(e);
|
||||
}
|
||||
return this.procceedJwtTokenValidate();
|
||||
} else if (username && password) {
|
||||
const loginRequest: LoginRequest = {
|
||||
username: username,
|
||||
password: password
|
||||
};
|
||||
return this.http.post<LoginResponse>('/api/auth/login', loginRequest, defaultHttpOptions()).pipe(
|
||||
tap((loginResponse: LoginResponse) => {
|
||||
try {
|
||||
this.updateAndValidateToken(loginResponse.token, 'jwt_token', false);
|
||||
this.updateAndValidateToken(loginResponse.refreshToken, 'refresh_token', false);
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
), mergeMap( () => {
|
||||
return this.procceedJwtTokenValidate();
|
||||
}
|
||||
));
|
||||
}
|
||||
return this.procceedJwtTokenValidate(doTokenRefresh);
|
||||
} else {
|
||||
|
||||
@ -22,7 +22,7 @@ import { PageComponent } from '@shared/components/page.component';
|
||||
import { FormBuilder } from '@angular/forms';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { Constants } from '@shared/models/constants';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'tb-login',
|
||||
@ -39,17 +39,11 @@ export class LoginComponent extends PageComponent implements OnInit {
|
||||
constructor(protected store: Store<AppState>,
|
||||
private authService: AuthService,
|
||||
public fb: FormBuilder,
|
||||
private router: Router,
|
||||
private route: ActivatedRoute) {
|
||||
private router: Router) {
|
||||
super(store);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.route.snapshot.queryParams.username && this.route.snapshot.queryParams.password) {
|
||||
this.loginFormGroup.setValue({username: this.route.snapshot.queryParams.username,
|
||||
password: this.route.snapshot.queryParams.password});
|
||||
this.login();
|
||||
}
|
||||
}
|
||||
|
||||
login(): void {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user