update
This commit is contained in:
+20
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user