diff --git a/idp/src/model/entity/activity-log.entity.ts b/idp/src/model/entity/activity-log.entity.ts index 98f2d8e..2d71988 100644 --- a/idp/src/model/entity/activity-log.entity.ts +++ b/idp/src/model/entity/activity-log.entity.ts @@ -19,6 +19,9 @@ export class ActivityLog { @Column({ default: 0, type: 'int' }) loginCounter: number; + @Column({ default: 0, type: 'int' }) + applicationLogin: number; + @Column({ default: 0, type: 'int' }) accessTokensVerifies: number; @@ -38,7 +41,14 @@ export class ActivityLogRepository extends Repository { return this.save(entity); } + async logApplicationLogin(): Promise { + const entity = await this.getTodaysActivityLog(); + entity.applicationLogin += 1; + return this.save(entity); + } + async logLogin(): Promise { + console.log("LOGIN") const entity = await this.getTodaysActivityLog(); entity.loginCounter += 1; return this.save(entity); diff --git a/idp/src/users/users.service.ts b/idp/src/users/users.service.ts index a3d39ac..4b4ec17 100644 --- a/idp/src/users/users.service.ts +++ b/idp/src/users/users.service.ts @@ -273,6 +273,7 @@ export class UsersService { }); const session = await this.sessionRepo.save(s); user.session_key = session.id; + this.activityRepo.logApplicationLogin(); return user; } diff --git a/idp_client/src/app/auth/user.service.ts b/idp_client/src/app/auth/user.service.ts index 45bd901..76dbf72 100644 --- a/idp_client/src/app/auth/user.service.ts +++ b/idp_client/src/app/auth/user.service.ts @@ -1,10 +1,12 @@ -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { User } from '../model/user.interface'; +import { Router } from '@angular/router'; @Injectable({ providedIn: 'root' }) export class UserService { + private router: Router = inject(Router); private _user: User; @@ -18,4 +20,11 @@ export class UserService { get user(): User { return this._user; } + + + logout() { + this.user = null; + localStorage.clear(); + this.router.navigateByUrl('/'); + } } diff --git a/idp_client/src/app/dashboard/dashboard.component.html b/idp_client/src/app/dashboard/dashboard.component.html index a1c3e47..25bbaf2 100644 --- a/idp_client/src/app/dashboard/dashboard.component.html +++ b/idp_client/src/app/dashboard/dashboard.component.html @@ -1,6 +1,10 @@
SSO Beantastic
-
{{ userName }}
+
+
{{ userName }}
+
+
+
diff --git a/idp_client/src/app/dashboard/dashboard.component.scss b/idp_client/src/app/dashboard/dashboard.component.scss index 5e397f1..59cf08a 100644 --- a/idp_client/src/app/dashboard/dashboard.component.scss +++ b/idp_client/src/app/dashboard/dashboard.component.scss @@ -60,4 +60,20 @@ align-items: flex-start; gap: 32px; justify-content: center; +} + +.logout{ + width: 32px; + height: 32px; + cursor: pointer; + background-color: transparent; + background-position: center; + background-size: 20px; + background-repeat: no-repeat; + border-radius: 4px; + transition: all 0.2s ease-in-out; + + &:hover { + background-color: #ccc; + } } \ No newline at end of file diff --git a/idp_client/src/app/dashboard/dashboard.component.ts b/idp_client/src/app/dashboard/dashboard.component.ts index 78acaf2..5b507e8 100644 --- a/idp_client/src/app/dashboard/dashboard.component.ts +++ b/idp_client/src/app/dashboard/dashboard.component.ts @@ -117,6 +117,9 @@ export class DashboardComponent implements OnInit { }) } + logout() { + this.userService.logout(); + } } diff --git a/idp_client/src/assets/icons/logout.svg b/idp_client/src/assets/icons/logout.svg new file mode 100644 index 0000000..d0f5ce4 --- /dev/null +++ b/idp_client/src/assets/icons/logout.svg @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/idp_client/src/styles.scss b/idp_client/src/styles.scss index b1be1c4..3b861d8 100644 --- a/idp_client/src/styles.scss +++ b/idp_client/src/styles.scss @@ -16,6 +16,10 @@ html, body { background-image: url("assets/icons/user.svg"); } +.logout { + background-image: url("assets/icons/logout.svg"); +} + .flex-row{ display: flex; flex-direction: row;