This commit is contained in:
baodev0
2026-09-23 15:17:18 +07:00
parent cd38c5d6d0
commit 82a71244ca
107 changed files with 3332 additions and 3306 deletions
+20 -1
View File
@@ -24,6 +24,16 @@ class Customer extends Authenticatable implements JWTSubject
return ['uuid'];
}
/**
* Điểm tích luỹ cộng cho một khoản nạp: 1 credit / 100 VNĐ.
* Trước đây khớp sao kê tự động cộng credit bằng nguyên số tiền còn duyệt tay cộng
* amount/100, cùng một khoản ra hai kết quả lệch nhau 100 lần — nay đi chung một chỗ.
*/
public static function creditFor(int $amount): int
{
return (int) floor(max(0, $amount) / 100);
}
protected $fillable = [
'fullname',
'username',
@@ -291,6 +301,15 @@ class Customer extends Authenticatable implements JWTSubject
public function getJWTCustomClaims()
{
return [];
return ['pv' => $this->passwordVersion()];
}
/**
* Dấu vân tay của hash mật khẩu, nhúng vào JWT. Đổi/đặt lại mật khẩu → giá trị đổi →
* mọi access token cũ bị ApiAuthCheck từ chối (không cần blacklist).
*/
public function passwordVersion(): string
{
return substr(hash('sha256', (string) $this->password), 0, 16);
}
}