Check if user is enabled first before verifying/resending verification email
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index 4f06c9a..f61486b 100644
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -381,24 +381,29 @@
return View::make("home");
}else{
try{
- $verified = EmailUtilities::verifyEmailVerification($username, $code);
- if (!$verified){
- $user_profile = Keycloak::getUserProfile($username);
- EmailUtilities::sendVerifyEmailAccount($username,
- $user_profile["firstname"], $user_profile["lastname"], $user_profile["email"]);
- CommonUtilities::print_error_message("Account confirmation "
- . "failed! We're sending another confirmation email. "
- . "Please click the link in the confirmation email that "
- . "you should be receiving soon.");
- return View::make("home");
- }
- $result = IamAdminServicesUtilities::enableUser($username);
- if($result){
- $this->sendAccountCreationNotification2Admin($username);
- return Redirect::to("login")->with("account-created-success", "Your account has been successfully created. Please log in now.");
- }else{
- CommonUtilities::print_error_message("Account confirmation failed! Please contact the Gateway Admin");
- return View::make("home");
+ $enabled = IamAdminServicesUtilities::isUserEnabled($username);
+ if ($enabled) {
+ return Redirect::to("login")->with("account-created-success", "Your account has already been successfully created. Please log in now.");
+ } else {
+ $verified = EmailUtilities::verifyEmailVerification($username, $code);
+ if (!$verified){
+ $user_profile = Keycloak::getUserProfile($username);
+ EmailUtilities::sendVerifyEmailAccount($username,
+ $user_profile["firstname"], $user_profile["lastname"], $user_profile["email"]);
+ CommonUtilities::print_error_message("Account confirmation "
+ . "failed! We're sending another confirmation email. "
+ . "Please click the link in the confirmation email that "
+ . "you should be receiving soon.");
+ return View::make("home");
+ }
+ $result = IamAdminServicesUtilities::enableUser($username);
+ if($result){
+ $this->sendAccountCreationNotification2Admin($username);
+ return Redirect::to("login")->with("account-created-success", "Your account has been successfully created. Please log in now.");
+ }else{
+ CommonUtilities::print_error_message("Account confirmation failed! Please contact the Gateway Admin");
+ return View::make("home");
+ }
}
}catch (Exception $e){
CommonUtilities::print_error_message("Account confirmation failed! Please contact the Gateway Admin");
diff --git a/app/libraries/IamAdminServicesUtilities.php b/app/libraries/IamAdminServicesUtilities.php
index b5623c5..086e6f1 100644
--- a/app/libraries/IamAdminServicesUtilities.php
+++ b/app/libraries/IamAdminServicesUtilities.php
@@ -22,6 +22,11 @@
return IamAdminServices::enableUser($admin_authz_token, $username);
}
+ public static function isUserEnabled($username) {
+ $admin_authz_token = IamAdminServicesUtilities::getAdminAuthzToken();
+ return IamAdminServices::isUserEnabled($admin_authz_token, $username);
+ }
+
public static function resetUserPassword($username, $new_password) {
$admin_authz_token = IamAdminServicesUtilities::getAdminAuthzToken();