login
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
|||||||
ManyToOne,
|
ManyToOne,
|
||||||
DataSource,
|
DataSource,
|
||||||
Repository,
|
Repository,
|
||||||
|
CreateDateColumn,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
import { User } from './user.entity';
|
import { User } from './user.entity';
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
@@ -15,6 +16,9 @@ export class SessionKey {
|
|||||||
|
|
||||||
@ManyToOne(() => User, (user) => user.sessionKeys, { eager: true })
|
@ManyToOne(() => User, (user) => user.sessionKeys, { eager: true })
|
||||||
user: User;
|
user: User;
|
||||||
|
|
||||||
|
@CreateDateColumn()
|
||||||
|
createdAt: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|||||||
@@ -37,11 +37,16 @@ export class LoginComponent {
|
|||||||
const id = window.localStorage.getItem("auth_sesion_key");
|
const id = window.localStorage.getItem("auth_sesion_key");
|
||||||
if (!id ||id.length < 2) { return; }
|
if (!id ||id.length < 2) { return; }
|
||||||
|
|
||||||
this.toast.loading('Logging in...');
|
|
||||||
this.http.post(environment.api_url + 'auth/login-with-session-id', {
|
this.http.post(environment.api_url + 'auth/login-with-session-id', {
|
||||||
code: id,
|
code: id,
|
||||||
client_id: this.client_id
|
client_id: this.client_id
|
||||||
}).subscribe({
|
}).pipe(
|
||||||
|
this.toast.observe({
|
||||||
|
loading: 'Logging in...',
|
||||||
|
success: 'Logged in',
|
||||||
|
error: 'Invalid session, please log in with your credentials'
|
||||||
|
})
|
||||||
|
).subscribe({
|
||||||
next: (data) => {
|
next: (data) => {
|
||||||
if (data["code"] != null) {
|
if (data["code"] != null) {
|
||||||
location.href = this.redirectUri + "?code=" + data["code"];
|
location.href = this.redirectUri + "?code=" + data["code"];
|
||||||
|
|||||||
Reference in New Issue
Block a user