diff --git a/GoogleOauth.php b/GoogleOauth.php index 86affe59..0e38babc 100755 --- a/GoogleOauth.php +++ b/GoogleOauth.php @@ -49,7 +49,32 @@ function resources() { return ' - + + '; } } diff --git a/files/google_signin_normal.png b/files/google_signin_normal.png new file mode 100644 index 00000000..f27bb243 Binary files /dev/null and b/files/google_signin_normal.png differ diff --git a/files/google_signin_pressed.png b/files/google_signin_pressed.png new file mode 100644 index 00000000..4cb85e9b Binary files /dev/null and b/files/google_signin_pressed.png differ diff --git a/files/plugin.js b/files/plugin.js new file mode 100755 index 00000000..d12d6718 --- /dev/null +++ b/files/plugin.js @@ -0,0 +1,16 @@ +$(document).ready(function () { + //allow admin to set password directly + //include input for new password + var redirectUri = $("meta[name='redirectUri']").attr('content'); + var clientId = $("meta[name='clientId']").attr('content'); + // (disabled) Send all the params + //var url = window.location.href + //var state = ( url.match(/\?(.+)$/) || [,''])[1]; + // Send just the return param value + var urlParams = new URLSearchParams(window.location.search); + var state = urlParams.get('return') || ''; + var html = '
\ + Sign in with google\ +
'; + $(html).insertAfter('#login-form'); +}); \ No newline at end of file diff --git a/pages/assets/js/plugin.js b/pages/assets/js/plugin.js deleted file mode 100755 index ae12ba31..00000000 --- a/pages/assets/js/plugin.js +++ /dev/null @@ -1,19 +0,0 @@ - -$(document).ready(function() { - //allow admin to set password directly - //include input for new password - var frm = $('#login-form'); - var redirectUri = $("meta[name='redirectUri']").attr('content'); - var clientId = $("meta[name='clientId']").attr('content'); - // (disabled) Send all the params - //var url = window.location.href - //var state = ( url.match(/\?(.+)$/) || [,''])[1]; - // Send just the return param value - var urlParams = new URLSearchParams(window.location.search); - var state = urlParams.get('return') || ''; - $('Sign in with google').appendTo(frm); - - frm.children('#sign_with_google').on('click', function(){ - return false; - }); -}); diff --git a/pages/config_update.php b/pages/config_update.php index 8544ba74..7bda764d 100755 --- a/pages/config_update.php +++ b/pages/config_update.php @@ -6,7 +6,10 @@ plugin_config_set('clientId', strip_tags(gpc_get_string('prefClientID'))); plugin_config_set('clientSecret', strip_tags(gpc_get_string('prefClientSecret'))); -plugin_config_set('redirect_uri', config_get('path')."plugins/GoogleOauth/pages/redirect.php"); + +$redirecturi = config_get('path'); +if(substr($redirecturi, -1) == '/') $redirecturi = rtrim($redirecturi,'/'); +plugin_config_set('redirect_uri', $redirecturi.plugin_page( 'redirect')); form_security_purge( 'plugin_GoogleOauth_config_update' ); print_successful_redirect( plugin_page( 'config', true ) ); diff --git a/pages/redirect.php b/pages/redirect.php index 73a3a194..c15eac11 100755 --- a/pages/redirect.php +++ b/pages/redirect.php @@ -8,9 +8,9 @@ $client = new Google_Client(); $client->setApplicationName("MantisBT Google authentication module"); -$client->setClientId(config_get(plugin_GoogleOauth_clientId)); -$client->setClientSecret(config_get(plugin_GoogleOauth_clientSecret)); -$client->setRedirectUri(config_get(plugin_GoogleOauth_redirect_uri)); +$client->setClientId(config_get( 'plugin_GoogleOauth_clientId' )); +$client->setClientSecret(config_get( 'plugin_GoogleOauth_clientSecret' )); +$client->setRedirectUri(config_get( 'plugin_GoogleOauth_redirect_uri')); $objOAuthService = new Google_Service_Oauth2($client);