You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2017/05/24 21:10:38 UTC

airavata-php-gateway git commit: AIRAVATA-2342 Success/error handling for reset password

Repository: airavata-php-gateway
Updated Branches:
  refs/heads/keycloak-integration c62cb173c -> 9f754b2de


AIRAVATA-2342 Success/error handling for reset password


Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/9f754b2d
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/9f754b2d
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/9f754b2d

Branch: refs/heads/keycloak-integration
Commit: 9f754b2de51c43f0c0fb3fe9a3e247c373f4be35
Parents: c62cb17
Author: Marcus Christie <ma...@iu.edu>
Authored: Wed May 24 17:08:37 2017 -0400
Committer: Marcus Christie <ma...@iu.edu>
Committed: Wed May 24 17:08:37 2017 -0400

----------------------------------------------------------------------
 app/controllers/AccountController.php       | 27 ++++++++++++------------
 app/views/account/forgot-password.blade.php | 15 +++++++++++++
 app/views/account/login.blade.php           |  5 +++++
 app/views/account/reset-password.blade.php  |  5 +++++
 4 files changed, 39 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9f754b2d/app/controllers/AccountController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index 7698ad3..a3a6194 100644
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -278,12 +278,10 @@ class AccountController extends BaseController
             try{
                 $user_profile = Keycloak::getUserProfile($username);
                 EmailUtilities::sendPasswordResetEmail($username, $user_profile["firstname"], $user_profile["lastname"], $user_profile["email"]);
-                CommonUtilities::print_success_message("Password reset notification was sent to your email account");
-                return View::make("home");
+                return Redirect::to("forgot-password")->with("forgot-password-success", "Password reset notification was sent to your email account");
             }catch (Exception $ex){
                 Log::error($ex);
-                CommonUtilities::print_error_message("Password reset operation failed");
-                return View::make("home");
+                return Redirect::to("forgot-password")->with("forgot-password-error", "Password reset operation failed");
             }
         }
     }
@@ -319,7 +317,7 @@ class AccountController extends BaseController
         $code = Input::get("code", Input::old("code"));
         $username = Input::get("username", Input::old("username"));
         if(empty($username) || empty($code)){
-            return View::make("home");
+            return Redirect::to("forgot-password")->with("password-reset-error", "Reset password link failed. Please request to reset user password again.");
         }else{
             return View::make("account/reset-password", array("code" => $code, "username"=>$username));
         }
@@ -431,8 +429,7 @@ class AccountController extends BaseController
         try{
             $verified = EmailUtilities::verifyPasswordResetCode($username, $code);
             if (!$verified){
-                CommonUtilities::print_error_message("Resetting user password operation failed. Please request to reset user password again.");
-                return View::make("home");
+                return Redirect::to("forgot-password")->with("password-reset-error", "Resetting user password operation failed. Please request to reset user password again.");
             }
 
             $admin_authz_token = Keycloak::getAdminAuthzToken();
@@ -440,15 +437,19 @@ class AccountController extends BaseController
 
             $result = IamAdminServices::resetUserPassword($admin_authz_token, $tenant_id, $username, $new_password);
             if($result){
-                CommonUtilities::print_success_message("User password was reset successfully");
-                return View::make("login");
+                return Redirect::to("login")->with("password-reset-success", "User password was reset successfully");
             }else{
-                CommonUtilities::print_error_message("Resetting user password operation failed");
-                return View::make("home");
+                Log::error("Failed to reset password for user $username");
+                return Redirect::to("reset-password")
+                    ->withInput(Input::except('new_password', 'confirm_new_password'))
+                    ->with("password-reset-error", "Resetting user password operation failed");
             }
         }catch (Exception $e){
-            CommonUtilities::print_error_message("Resetting user password operation failed");
-            return View::make("home");
+            Log::error("Failed to reset password for user $username");
+            Log::error($e);
+            return Redirect::to("reset-password")
+                ->withInput(Input::except('new_password', 'confirm_new_password'))
+                ->with("password-reset-error", "Resetting user password operation failed");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9f754b2d/app/views/account/forgot-password.blade.php
----------------------------------------------------------------------
diff --git a/app/views/account/forgot-password.blade.php b/app/views/account/forgot-password.blade.php
index 2fa2883..6fdc0d4 100644
--- a/app/views/account/forgot-password.blade.php
+++ b/app/views/account/forgot-password.blade.php
@@ -8,6 +8,21 @@
 
     <div class="col-md-offset-3 col-md-6">
 
+        @if( Session::has("forgot-password-success") )
+        <div class="alert alert-success">
+            {{{ Session::get("forgot-password-success") }}}
+        </div>
+        @endif
+        @if( Session::has("forgot-password-error") )
+        <div class="alert alert-danger">
+            {{{ Session::get("forgot-password-error") }}}
+        </div>
+        @endif
+        @if( Session::has("password-reset-error") )
+        <div class="alert alert-danger">
+            {{{ Session::get("password-reset-error") }}}
+        </div>
+        @endif
         <h3> Did you forget the password to your account? </h3>
         <h4> Please enter your username, you registered with.</h4>
         <form role="form" method="POST" action="{{ URL::to('/') }}/forgot-password">

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9f754b2d/app/views/account/login.blade.php
----------------------------------------------------------------------
diff --git a/app/views/account/login.blade.php b/app/views/account/login.blade.php
index bfbb152..f9305aa 100755
--- a/app/views/account/login.blade.php
+++ b/app/views/account/login.blade.php
@@ -25,6 +25,11 @@
             Your password has expired. Please <a href="{{URL::to('/') }}/forgot-password">reset your password</a>.
         </div>
         @endif
+        @if( Session::has("password-reset-success") )
+        <div class="alert alert-success">
+            {{{ Session::get("password-reset-success") }}}
+        </div>
+        @endif
 
         <div class="form-group">
             <label class="sr-only" for="username">Username</label>

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/9f754b2d/app/views/account/reset-password.blade.php
----------------------------------------------------------------------
diff --git a/app/views/account/reset-password.blade.php b/app/views/account/reset-password.blade.php
index 7bc07e0..6254415 100644
--- a/app/views/account/reset-password.blade.php
+++ b/app/views/account/reset-password.blade.php
@@ -9,6 +9,11 @@
 <div class="col-md-offset-3 col-md-6">
 
     <h3>Reset Password</h3>
+    @if( Session::has("password-reset-error") )
+    <div class="alert alert-danger">
+        {{{ Session::get("password-reset-error") }}}
+    </div>
+    @endif
     @if ($errors->has())
     @foreach ($errors->all() as $error)
     {{ CommonUtilities::print_error_message($error) }}