|
|
|
|
@ -8,14 +8,15 @@ class SupplyDemandAccess
|
|
|
|
|
{
|
|
|
|
|
use ApiResponse;
|
|
|
|
|
public static function registered($user): bool {
|
|
|
|
|
return $user && trim((string) $user->name) !== '' && preg_match('/^1\d{10}$/', (string) $user->getRawOriginal('mobile'));
|
|
|
|
|
return $user && preg_match('/^1\d{10}$/', (string) $user->getRawOriginal('mobile'));
|
|
|
|
|
}
|
|
|
|
|
private function tokenUser($bearer) {
|
|
|
|
|
if (!is_string($bearer) || $bearer === '') return null;
|
|
|
|
|
$token = PersonalAccessToken::findToken($bearer);
|
|
|
|
|
if (!$token || !($token->tokenable instanceof User)) return null;
|
|
|
|
|
if ($token->expires_at && !\Illuminate\Support\Carbon::parse($token->expires_at)->isFuture()) return null;
|
|
|
|
|
if (config('sanctum.expiration') && !$token->created_at->gt(now()->subMinutes(config('sanctum.expiration')))) return null;
|
|
|
|
|
// Match the existing mobile login lifecycle; token age alone does not log out a member.
|
|
|
|
|
// Revoked tokens and tokens with an explicit expiry remain invalid.
|
|
|
|
|
return $token->tokenable;
|
|
|
|
|
}
|
|
|
|
|
public function handle($request, Closure $next, $mode = 'member') {
|
|
|
|
|
|