refactor
This commit is contained in:
@@ -34,33 +34,9 @@ export class LoginComponent {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.getclient();
|
this.getclient();
|
||||||
this.loginWithSessionId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loginWithSessionId() {
|
|
||||||
const id = window.localStorage.getItem("auth_session_key");
|
|
||||||
if (!id ||id.length < 2) { return; }
|
|
||||||
|
|
||||||
const url = this.client_id ? 'api/auth/login-with-session-id' : 'api/auth/login-with-session-id/userlogin'
|
|
||||||
|
|
||||||
this.http.post(url, {
|
|
||||||
code: id,
|
|
||||||
client_id: this.client_id
|
|
||||||
}).pipe(
|
|
||||||
this.toast.observe({
|
|
||||||
loading: 'Logging in...',
|
|
||||||
success: 'Logged in',
|
|
||||||
error: 'Invalid session, please log in with your credentials'
|
|
||||||
})
|
|
||||||
).subscribe({
|
|
||||||
next: (data) => {
|
|
||||||
this.handleLoginData(data);
|
|
||||||
},
|
|
||||||
error: (error) => {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private handleLoginData(data: any) {
|
private handleLoginData(data: any) {
|
||||||
if (data["code"] != null) {
|
if (data["code"] != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user