#NEWLINE# @ routes . route ( org_scoped_rule ( '/login' ) , methods = [ 'GET' , 'POST' ] ) #NEWLINE# def login( org_slug = None ) : #NEWLINE# #INDENT# index_url = url_for ( 'redash.index' , org_slug = org_slug ) #NEWLINE# next_path = request . args . get ( 'next' , index_url ) #NEWLINE# if current_user . is_authenticated : #NEWLINE# #INDENT# return redirect ( next_path ) #NEWLINE# #UNINDENT# if ( not settings . PASSWORD_LOGIN_ENABLED ) : #NEWLINE# #INDENT# if settings . REMOTE_USER_LOGIN_ENABLED : #NEWLINE# #INDENT# return redirect ( url_for ( 'remote_user_auth.login' , next = next_path ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if settings . SAML_LOGIN_ENABLED : #NEWLINE# #INDENT# return redirect ( url_for ( 'saml_auth.sp_initiated' , next = next_path ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return redirect ( url_for ( 'google_oauth.authorize' , next = next_path ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# user = models . User . get_by_email_and_org ( request . form [ 'email' ] , current_org . id ) #NEWLINE# if ( user and user . verify_password ( request . form [ 'password' ] ) ) : #NEWLINE# #INDENT# remember = ( 'remember' in request . form ) #NEWLINE# login_user ( user , remember = remember ) #NEWLINE# return redirect ( user ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# flash ( 'Wrong email or password.' ) #NEWLINE# #UNINDENT# #UNINDENT# except models . User . DoesNotExist : #NEWLINE# #INDENT# flash ( 'Wrong email or password.' ) #NEWLINE# #UNINDENT# #UNINDENT# google_auth_url = get_google_auth_url ( next_path ) #NEWLINE# return render_template ( 'login.html' , org_slug = org_slug , next = next_path , username = request . form . get ( 'username' , '' ) , show_google_openid = settings . GOOGLE_OAUTH_ENABLED , google_auth_url = google_auth_url , show_saml_login = settings . SAML_LOGIN_ENABLED , show_remote_user_login = settings . REMOTE_USER_LOGIN_ENABLED )