#NEWLINE# @ collect_auth #NEWLINE# def auth_login( auth , **kwargs ) : #NEWLINE# #INDENT# 'If GET request, show login page. If POST, attempt to log user in if\n    login form passsed; else send forgot password email.\n\n    ' #NEWLINE# campaign = request . args . get ( 'campaign' ) #NEWLINE# next_url = request . args . get ( 'next' ) #NEWLINE# must_login_warning = True #NEWLINE# if campaign : #NEWLINE# #INDENT# next_url = campaigns . campaign_url_for ( campaign ) #NEWLINE# #UNINDENT# if ( not next_url ) : #NEWLINE# #INDENT# next_url = request . args . get ( 'redirect_url' ) #NEWLINE# must_login_warning = False #NEWLINE# #UNINDENT# if next_url : #NEWLINE# #INDENT# if ( not ( ( next_url [ 0 ] == '/' ) or next_url . startswith ( settings . DOMAIN ) ) ) : #NEWLINE# #INDENT# raise HTTPError ( http . InvalidURL ) #NEWLINE# #UNINDENT# #UNINDENT# if auth . logged_in : #NEWLINE# #INDENT# if ( not request . args . get ( 'logout' ) ) : #NEWLINE# #INDENT# if next_url : #NEWLINE# #INDENT# return redirect ( next_url ) #NEWLINE# #UNINDENT# return redirect ( '/' ) #NEWLINE# #UNINDENT# return auth_logout ( redirect_url = request . url ) #NEWLINE# #UNINDENT# if kwargs . get ( 'first' , False ) : #NEWLINE# #INDENT# status . push_status_message ( 'You may now log in' , kind = 'info' , trust = False ) #NEWLINE# #UNINDENT# status_message = request . args . get ( 'status' , '' ) #NEWLINE# if ( redirect_url == 'expired' ) : #NEWLINE# #INDENT# status . push_status_message ( 'The private link you used is expired.' , trust = False ) #NEWLINE# #UNINDENT# if ( next_url and must_login_warning ) : #NEWLINE# #INDENT# status . push_status_message ( language . MUST_LOGIN , trust = False ) #NEWLINE# #UNINDENT# redirect_url = web_url_for ( 'auth_login' , next = next_url , _absolute = True ) #NEWLINE# data = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( campaign and ( campaign in campaigns . CAMPAIGNS ) ) : #NEWLINE# #INDENT# if ( ( ( campaign == 'institution' ) and settings . ENABLE_INSTITUTIONS ) or ( campaign != 'institution' ) ) : #NEWLINE# #INDENT# data [ 'campaign' ] = campaign #NEWLINE# #UNINDENT# #UNINDENT# data [ 'login_url' ] = cas . get_login_url ( redirect_url , auto = True ) #NEWLINE# data [ 'institution_redirect' ] = cas . get_institution_target ( redirect_url ) #NEWLINE# data [ 'redirect_url' ] = next_url #NEWLINE# data [ 'sign_up' ] = request . args . get ( 'sign_up' , False ) #NEWLINE# return ( data , http . OK )