-เพิ่ม pkg jose ไว้ encrypt secret key
All checks were successful
Build Docker Image / Build Docker Image (push) Successful in 6m5s
All checks were successful
Build Docker Image / Build Docker Image (push) Successful in 6m5s
-jwt services/jwt.service.ts -เพิ่ม เวลา expire jwt token
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Component, HostListener, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { trigger, state, style, transition, animate } from '@angular/animations';
|
||||
import { JwtService } from '../../services/jwt.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sidebar',
|
||||
@@ -28,7 +29,10 @@ export class SidebarComponent implements OnInit {
|
||||
isMobile = false; // ตรวจอุปกรณ์
|
||||
showOverlay = false; // สำหรับ mobile overlay
|
||||
|
||||
constructor(private router: Router) {}
|
||||
constructor(
|
||||
private router: Router,
|
||||
private jwtService: JwtService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.checkDevice();
|
||||
@@ -60,7 +64,6 @@ export class SidebarComponent implements OnInit {
|
||||
}
|
||||
|
||||
logout() {
|
||||
localStorage.removeItem('access_token');
|
||||
this.router.navigate(['/login']);
|
||||
this.jwtService.logout();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
.token-timer {
|
||||
position: fixed;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
background-color: #f8d7da;
|
||||
color: #721c24;
|
||||
padding: 10px;
|
||||
border: 1px solid #f5c6cb;
|
||||
border-radius: 5px;
|
||||
width: 10rem;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<div *ngIf="countdown$ | async as countdown" class="token-timer">
|
||||
<p>หมดอายุใน: {{ countdown }}</p>
|
||||
</div>
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { JwtService } from '../../services/jwt.service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-token-timer',
|
||||
standalone: false,
|
||||
templateUrl: './token-timer.component.html',
|
||||
styleUrls: ['./token-timer.component.css']
|
||||
})
|
||||
export class TokenTimerComponent implements OnInit {
|
||||
countdown$: Observable<string | null>;
|
||||
|
||||
constructor(private jwtService: JwtService) {
|
||||
this.countdown$ = this.jwtService.countdown$;
|
||||
}
|
||||
|
||||
ngOnInit(): void {}
|
||||
}
|
||||
Reference in New Issue
Block a user