Skip to content

Commit

Permalink
api/oauth: also activate user after successful oauth authentication
Browse files Browse the repository at this point in the history
Issue: #4670
  • Loading branch information
BacLuc committed Mar 16, 2024
1 parent ede0e00 commit 80ae096
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion api/src/Security/OAuth/GoogleAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,16 @@ public function authenticate(Request $request): Passport {
$existingProfile = $profileRepository->findOneBy(['googleId' => $googleUser->getId()]);

if ($existingProfile) {
return $existingProfile->user;
$user = $existingProfile->user;
if (User::STATE_REGISTERED === $user->state
|| User::STATE_NONREGISTERED === $user->state
) {
$user->state = User::STATE_ACTIVATED;
$this->entityManager->persist($user);
$this->entityManager->flush();
}

return $user;
}

// do we have a matching user by email?
Expand Down
11 changes: 10 additions & 1 deletion api/src/Security/OAuth/HitobitoAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ public function authenticate(Request $request): Passport {
$existingProfile = $profileRepository->findOneBy(["{$provider}Id" => $hitobitoUser->getId()]);

if ($existingProfile) {
return $existingProfile->user;
$user = $existingProfile->user;
if (User::STATE_REGISTERED === $user->state
|| User::STATE_NONREGISTERED === $user->state
) {
$user->state = User::STATE_ACTIVATED;
$this->entityManager->persist($user);
$this->entityManager->flush();
}

return $user;
}

// do we have a matching user by email?
Expand Down

0 comments on commit 80ae096

Please sign in to comment.