From 775539f68762fee74694fa20fac371e33ff5945e Mon Sep 17 00:00:00 2001 From: Bastian Wagner Date: Sun, 25 Aug 2024 20:48:14 +0200 Subject: [PATCH] login --- idp/src/model/session-key.entity.ts | 4 ++++ idp_client/src/app/auth/login/login.component.ts | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/idp/src/model/session-key.entity.ts b/idp/src/model/session-key.entity.ts index f8a73d6..3d2b96e 100644 --- a/idp/src/model/session-key.entity.ts +++ b/idp/src/model/session-key.entity.ts @@ -4,6 +4,7 @@ import { ManyToOne, DataSource, Repository, + CreateDateColumn, } from 'typeorm'; import { User } from './user.entity'; import { Injectable } from '@nestjs/common'; @@ -15,6 +16,9 @@ export class SessionKey { @ManyToOne(() => User, (user) => user.sessionKeys, { eager: true }) user: User; + + @CreateDateColumn() + createdAt: Date; } @Injectable() diff --git a/idp_client/src/app/auth/login/login.component.ts b/idp_client/src/app/auth/login/login.component.ts index aa6cbd4..464e8f2 100644 --- a/idp_client/src/app/auth/login/login.component.ts +++ b/idp_client/src/app/auth/login/login.component.ts @@ -37,11 +37,16 @@ export class LoginComponent { const id = window.localStorage.getItem("auth_sesion_key"); if (!id ||id.length < 2) { return; } - this.toast.loading('Logging in...'); this.http.post(environment.api_url + 'auth/login-with-session-id', { code: 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) => { if (data["code"] != null) { location.href = this.redirectUri + "?code=" + data["code"];