AIRAVATA-2478 Fix error handling when email can't be updated

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/7802782a
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/7802782a
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/7802782a

Branch: refs/heads/dreg-gateway
Commit: 7802782a1f90aad7b9a1ca789d0e3634d32c2896
Parents: 5d992bb
Author: Marcus Christie <machr...@iu.edu>
Authored: Tue Jul 4 17:55:33 2017 -0400
Committer: Marcus Christie <machr...@iu.edu>
Committed: Tue Jul 4 17:55:33 2017 -0400

----------------------------------------------------------------------
 app/controllers/UserSettingsController.php            | 13 +++++++++++--
 app/views/account/user-profile-update-email.blade.php |  4 ++--
 2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/7802782a/app/controllers/UserSettingsController.php
----------------------------------------------------------------------
diff --git a/app/controllers/UserSettingsController.php 
b/app/controllers/UserSettingsController.php
index 959c5dc..d73e874 100644
--- a/app/controllers/UserSettingsController.php
+++ b/app/controllers/UserSettingsController.php
@@ -220,7 +220,14 @@ class UserSettingsController extends BaseController
     }
 
     public function showUpdateEmailView() {
-        $userProfile = 
UserProfileUtilities::get_user_profile(Session::get("username"));
+        try {
+            $userProfile = 
UserProfileUtilities::get_user_profile(Session::get("username"));
+        } catch (Exception $e) {
+            Log::error("Failed to retrieve user profile. Error: " . 
$e->getMessage());
+            return View::make("account/user-profile-update-email", array(
+                "email" => null
+            ));
+        }
         return View::make("account/user-profile-update-email", array(
             "email" => $userProfile->emails[0]
         ));
@@ -272,8 +279,10 @@ class UserSettingsController extends BaseController
                     "errorMessage", "Failed to update email address, please 
try again. Reason: confirmation link was not verified successfully.");
             }
         } catch (Exception $e) {
+            Log::error("Failed to update email address", array(Input::all()));
+            Log::error($e);
             return Redirect::to("account/user-profile-update-email")->with(
-                "errorMessage", "Failed to update email address, please try 
again. Reason: " . $e->message);
+                "errorMessage", "Failed to update email address, please try 
again. Reason: " . $e->getMessage());
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/7802782a/app/views/account/user-profile-update-email.blade.php
----------------------------------------------------------------------
diff --git a/app/views/account/user-profile-update-email.blade.php 
b/app/views/account/user-profile-update-email.blade.php
index ea05bfb..11454f2 100644
--- a/app/views/account/user-profile-update-email.blade.php
+++ b/app/views/account/user-profile-update-email.blade.php
@@ -22,9 +22,9 @@
         </div>
     @endif
 
-    @if( isset($errorMessage) )
+    @if( Session::has("errorMessage") )
         <div class="alert alert-danger" role="alert">
-            {{{ $errorMessage }}}
+            {{{ Session::get("errorMessage") }}}
         </div>
     @endif
 

Reply via email to