|
|
@@ -48,7 +48,7 @@ class AuthService
|
|
|
];
|
|
|
}
|
|
|
|
|
|
- public function refresh(string $refreshToken): ?array
|
|
|
+ public function refresh(string $refreshToken, bool $isApp = false): ?array
|
|
|
{
|
|
|
if (! $refreshToken) {
|
|
|
return null;
|
|
|
@@ -71,7 +71,7 @@ class AuthService
|
|
|
|
|
|
$deviceId = Str::afterLast($tokenModel->name, '_');
|
|
|
|
|
|
- $tokens = $this->refreshTokenTransaction($tokenModel, $user, $deviceId);
|
|
|
+ $tokens = $this->refreshTokenTransaction($tokenModel, $user, $deviceId, $isApp);
|
|
|
|
|
|
return [
|
|
|
'payload' => [
|
|
|
@@ -102,16 +102,22 @@ class AuthService
|
|
|
PersonalAccessToken $tokenModel,
|
|
|
User $user,
|
|
|
string $deviceId,
|
|
|
+ bool $isApp = false,
|
|
|
): array {
|
|
|
return DB::transaction(function () use (
|
|
|
$tokenModel,
|
|
|
$user,
|
|
|
$deviceId,
|
|
|
+ $isApp,
|
|
|
): array {
|
|
|
$tokenModel->update(['expires_at' => Carbon::now()]);
|
|
|
|
|
|
- $accessToken = $user->createAccessToken($deviceId);
|
|
|
- $refreshToken = $user->createRefreshToken($deviceId);
|
|
|
+ $accessToken = $isApp
|
|
|
+ ? $user->createAccessTokenApp($deviceId)
|
|
|
+ : $user->createAccessToken($deviceId);
|
|
|
+ $refreshToken = $isApp
|
|
|
+ ? $user->createRefreshTokenApp($deviceId)
|
|
|
+ : $user->createRefreshToken($deviceId);
|
|
|
|
|
|
return [
|
|
|
'access_token' => $accessToken,
|
|
|
@@ -221,15 +227,15 @@ class AuthService
|
|
|
return ['error' => 'wrong_user_type'];
|
|
|
}
|
|
|
|
|
|
- if ($user->registration_complete) {
|
|
|
- $provider = Provider::where('user_id', $user->id)->first();
|
|
|
- if ($provider && $provider->approval_status->value !== ApprovalStatusEnum::ACCEPTED->value) {
|
|
|
- DB::rollBack();
|
|
|
+ // if ($user->registration_complete) {
|
|
|
+ $provider = Provider::where('user_id', $user->id)->first();
|
|
|
+ if ($provider && $provider->approval_status->value !== ApprovalStatusEnum::ACCEPTED->value) {
|
|
|
+ DB::rollBack();
|
|
|
|
|
|
- return ['error' => 'provider_not_accepted'];
|
|
|
- }
|
|
|
- $isLogin = true;
|
|
|
+ return ['error' => 'provider_not_accepted'];
|
|
|
}
|
|
|
+ $isLogin = true;
|
|
|
+ // }
|
|
|
|
|
|
$user->code = $code;
|
|
|
$user->validated_code = false;
|
|
|
@@ -324,9 +330,9 @@ class AuthService
|
|
|
$user->load('provider');
|
|
|
$provider = $user->provider ?? null;
|
|
|
|
|
|
- if (! $user->registration_complete || ! $provider) {
|
|
|
- return ['error' => 'registration_incomplete'];
|
|
|
- }
|
|
|
+ // if (! $user->registration_complete || ! $provider) {
|
|
|
+ // return ['error' => 'registration_incomplete'];
|
|
|
+ // }
|
|
|
|
|
|
if ($provider->approval_status === ApprovalStatusEnum::PENDING->value) {
|
|
|
return ['error' => 'provider_pending'];
|