Skip to content

Instantly share code, notes, and snippets.

@tony2001
Created March 18, 2016 12:43
Show Gist options
  • Save tony2001/3a0f48e54ff48de3cc4b to your computer and use it in GitHub Desktop.
Save tony2001/3a0f48e54ff48de3cc4b to your computer and use it in GitHub Desktop.
diff --git a/application/classes/Auth/GPlus.php b/application/classes/Auth/GPlus.php
index 0040d06..69d94e2 100644
--- a/application/classes/Auth/GPlus.php
+++ b/application/classes/Auth/GPlus.php
@@ -128,7 +128,10 @@ class Auth_GPlus extends Auth {
try {
$plus = GPlus::instance();
$userInfo = $plus->getUserinfo();
- } catch (Google_AuthException $e) {
+ } catch (Google_Exception $e) {
+ $session = Session::instance();
+ $session->set("last_alert", __("Google Auth failure, please log in again"));
+ $session->set("last_alert_type", "warning");
$this->logout();
HTTP::redirect('/');
}
diff --git a/application/classes/Controller/Page.php b/application/classes/Controller/Page.php
index 2d72959..ca1e866 100644
--- a/application/classes/Controller/Page.php
+++ b/application/classes/Controller/Page.php
@@ -40,6 +40,20 @@ abstract class Controller_Page extends Controller_Template {
parent::__construct($request, $response);
+ $session = Session::instance();
+ $alert = $session->get("last_alert");
+ $alert_type = $session->get("last_alert_type");
+ if (is_string($alert)) {
+ if ($alert_type) {
+ $this->set_alert($alert, $alert_type);
+ } else {
+ $this->set_alert($alert);
+ }
+
+ $session->delete("last_alert");
+ $session->delete("last_alert_type");
+ }
+
if (Auth::instance()->logged_in()) {
$this->user = Auth::instance()->get_user();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment