From cb7f25cdd7c94dd4a8dfc48f1790c8977e15c3bb Mon Sep 17 00:00:00 2001 From: Virus-x2 Date: Wed, 24 Feb 2021 14:23:16 +0300 Subject: [PATCH 1/2] Update plugin.php resolves issue #15 and #12 --- plugin.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin.php b/plugin.php index 2cf5afc..0caa057 100644 --- a/plugin.php +++ b/plugin.php @@ -47,7 +47,10 @@ function atomarch_google_auth() { if (isset($_SESSION['access_token']) && $_SESSION['access_token']) { // User has already authenticated against google with an approved domain, nothing to do - return true; + $google_oauthV2 = new Google_Service_Oauth2($google_client); + $user_info = $google_oauthV2->userinfo->get(); + yourls_set_user($user_info['email']); + return true; } else { @@ -99,6 +102,7 @@ function atomarch_check_domain($google_client) { $user_domain = substr(strrchr($user_info['email'], "@"), 1); if (in_array($user_domain, $APPROVED_DOMAINS)) { + yourls_set_user($user_info['email']); return true; } else { return false; From 353365a32940a2a0a198f29f7c6096dea3db1215 Mon Sep 17 00:00:00 2001 From: Virus-x2 Date: Sun, 31 Oct 2021 01:40:18 +0300 Subject: [PATCH 2/2] Update plugin.php corrected errors --- plugin.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/plugin.php b/plugin.php index 0caa057..cd3fe93 100644 --- a/plugin.php +++ b/plugin.php @@ -47,9 +47,7 @@ function atomarch_google_auth() { if (isset($_SESSION['access_token']) && $_SESSION['access_token']) { // User has already authenticated against google with an approved domain, nothing to do - $google_oauthV2 = new Google_Service_Oauth2($google_client); - $user_info = $google_oauthV2->userinfo->get(); - yourls_set_user($user_info['email']); + yourls_set_user($_SESSION['google_oauth_user']); return true; } else { @@ -91,18 +89,15 @@ function atomarch_check_domain($google_client) { //$APPROVED_DOMAINS = array("domain1.com", "domain2.com"); $APPROVED_DOMAINS = array("*"); - if (in_array("*", $APPROVED_DOMAINS)) { - return true; - } - if (isset($_SESSION['access_token']) && $_SESSION['access_token']) { $google_oauthV2 = new Google_Service_Oauth2($google_client); $user_info = $google_oauthV2->userinfo->get(); $user_domain = substr(strrchr($user_info['email'], "@"), 1); - if (in_array($user_domain, $APPROVED_DOMAINS)) { - yourls_set_user($user_info['email']); + if ((in_array($user_domain, $APPROVED_DOMAINS)) || (in_array("*", $APPROVED_DOMAINS))) { + $_SESSION['google_oauth_user'] = $user_info['email']; + yourls_set_user($_SESSION['google_oauth_user']); return true; } else { return false;