feat: implement JWT-based authentication system with repository, service, and middleware layers
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace WorkbloomERP\Security;
|
||||
|
||||
class AuthContext {
|
||||
private static ?array $user = null;
|
||||
|
||||
public static function setUser(array $user): void {
|
||||
self::$user = $user;
|
||||
}
|
||||
|
||||
public static function getUser(): ?array {
|
||||
return self::$user;
|
||||
}
|
||||
|
||||
public static function getUserId(): ?int {
|
||||
return isset(self::$user['id']) ? (int)self::$user['id'] : null;
|
||||
}
|
||||
|
||||
public static function getUserUuid(): ?string {
|
||||
return self::$user['sub'] ?? self::$user['uuid'] ?? null;
|
||||
}
|
||||
|
||||
public static function clear(): void {
|
||||
self::$user = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user