|
|
@@ -6,13 +6,13 @@
|
|
|
use App\DataTransferObjects\AuthDto;
|
|
|
use App\DataTransferObjects\RefreshTokenDto;
|
|
|
use Illuminate\Support\Str;
|
|
|
+use Illuminate\Support\Facades\Auth;
|
|
|
|
|
|
class AuthService
|
|
|
{
|
|
|
public function __construct(
|
|
|
protected AuthRepositoryInterface $authRepository,
|
|
|
- ) {
|
|
|
- }
|
|
|
+ ) {}
|
|
|
|
|
|
public function login(AuthDto $credentials): ?array
|
|
|
{
|
|
|
@@ -57,13 +57,15 @@ public function refresh(RefreshTokenDto $refreshToken): ?array
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
- public function logout(string $deviceId): void
|
|
|
+ public function logout(): void
|
|
|
{
|
|
|
- $user = auth()->user();
|
|
|
+ $user = Auth::user();
|
|
|
+ $tokenName = $user->currentAccessToken()->name;
|
|
|
+ $deviceId = Str::afterLast($tokenName, '_');
|
|
|
if (!$user) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$this->authRepository->deleteUserTokensByDevice($user, $deviceId);
|
|
|
}
|
|
|
-}
|
|
|
+}
|