Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update plugin.php #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ 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;
yourls_set_user($_SESSION['google_oauth_user']);
return true;

} else {

Expand Down Expand Up @@ -88,17 +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)) {
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;
Expand Down