Skip to content

Commit f1803f0

Browse files
committed
allowing prompt and login_hint params to be configured
nraboy#128
1 parent a605530 commit f1803f0

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

dist/ng-cordova-oauth.js

+14-18
Original file line numberDiff line numberDiff line change
@@ -687,33 +687,29 @@ function google($q, $http, $cordovaOauthUtility) {
687687

688688
if($cordovaOauthUtility.isInAppBrowserInstalled()) {
689689

690-
var redirect_uri = "http://localhost/callback",
691-
clear_cache = 'no',
692-
clear_session = 'no',
693-
approval_prompt = 'auto';
690+
var redirect_uri, clear_cache, clear_session, approval_prompt, prompt, login_hint;
691+
692+
options = options || {};
693+
694+
redirect_uri = options.redirect_uri || "http://localhost/callback";
695+
clear_cache = options.clear_cache === true ? 'yes' : 'no';
696+
clear_session = options.clear_session === true ? 'yes' : 'no';
697+
approval_prompt = options.approval_prompt === true ? 'force' : 'auto';
698+
prompt = options.prompt === true ? 'select_account' : 'consent select_account';
699+
login_hint = options.login_hint || '';
694700

695-
if(options !== undefined) {
696-
if(options.hasOwnProperty("redirect_uri")) {
697-
redirect_uri = options.redirect_uri;
698-
}
699-
if(options.hasOwnProperty("clear_cache")) {
700-
clear_cache = options.clear_cache === true ? 'yes' : 'no';
701-
}
702-
if(options.hasOwnProperty("clear_session")) {
703-
clear_session = options.clear_session === true ? 'yes' : 'no';
704-
}
705-
if(options.hasOwnProperty("approval_prompt")) {
706-
approval_prompt = options.approval_prompt === true ? 'force' : 'auto';
707-
}
708-
}
709701

710702
var browserRef = window.cordova.InAppBrowser.open(
711703
'https://accounts.google.com/o/oauth2/auth?client_id=' + clientId
712704
+ '&redirect_uri=' + redirect_uri
713705
+ '&scope=' + appScope.join(" ")
714706
+ '&approval_prompt=' + approval_prompt
715707
+ '&response_type=token'
708+
+ '&prompt=' + prompt
709+
+ '&login_hint=' + login_hint
710+
716711
, '_blank'
712+
717713
, 'location=no,clearsessioncache=' + clear_session
718714
+ ',clearcache=' + clear_cache
719715
);

0 commit comments

Comments
 (0)