@@ -88,7 +88,17 @@ def login():
8888 next_path = request .args .get ('next' , url_for ("redash.index" , org_slug = session .get ('org_slug' )))
8989 logger .debug ("Callback url: %s" , callback )
9090 logger .debug ("Next is: %s" , next_path )
91- return google_remote_app ().authorize (callback = callback , state = next_path )
91+ extra = {}
92+ if 'org_slug' in session :
93+ org = models .Organization .get_by_slug (session .pop ('org_slug' ))
94+ else :
95+ org = current_org
96+ if org .google_apps_domains :
97+ extra ['hd' ] = org .google_apps_domains [0 ]
98+ if session .get ('relogin' ) == '1' :
99+ extra ['prompt' ] = 'consent'
100+ session ['relogin' ] = '0'
101+ return google_remote_app ().authorize (callback = callback , state = next_path , ** extra )
92102
93103
94104@blueprint .route ('/oauth/google_callback' , endpoint = "callback" )
@@ -113,7 +123,7 @@ def authorized():
113123
114124 if not verify_profile (org , profile ):
115125 logger .warning ("User tried to login with unauthorized domain name: %s (org: %s)" , profile ['email' ], org )
116- flash ( "Your Google Apps account ({}) isn't allowed." . format ( profile [ 'email' ]))
126+ session [ 'relogin' ] = '1'
117127 return redirect (url_for ('redash.login' , org_slug = org .slug ))
118128
119129 create_and_login_user (org , profile ['name' ], profile ['email' ])
0 commit comments