airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata-php-gateway] 02/03: Check if user is enabled first before verifying/resending verification email
Date Mon, 11 Jun 2018 18:30:55 GMT
This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-php-gateway.git

commit 619dade6ea18ab3542a856caf4fba2cbe26178f4
Author: Marcus Christie <machrist@iu.edu>
AuthorDate: Mon Jun 11 14:29:55 2018 -0400

    Check if user is enabled first before verifying/resending verification email
---
 app/controllers/AccountController.php       | 41 ++++++++++++++++-------------
 app/libraries/IamAdminServicesUtilities.php |  5 ++++
 2 files changed, 28 insertions(+), 18 deletions(-)

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 @@ class AccountController extends BaseController
             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 @@ class IamAdminServicesUtilities {
         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();

-- 
To stop receiving notification emails like this one, please contact
machristie@apache.org.

Mime
View raw message