#NEWLINE# @ collect_auth #NEWLINE# def confirm_email_get( token , auth = None , **kwargs ) : #NEWLINE# #INDENT# 'View for email confirmation links.\n    Authenticates and redirects to user settings page if confirmation is\n    successful, otherwise shows an "Expired Link" error.\n\n    methods: GET\n    ' #NEWLINE# user = User . load ( kwargs [ 'uid' ] ) #NEWLINE# is_merge = ( 'confirm_merge' in request . args ) #NEWLINE# is_initial_confirmation = ( not user . date_confirmed ) #NEWLINE# if ( user is None ) : #NEWLINE# #INDENT# raise HTTPError ( http . NOT_FOUND ) #NEWLINE# #UNINDENT# if ( auth and auth . user and ( ( auth . user . _id == user . _id ) or ( auth . user . _id == user . merged_by . _id ) ) ) : #NEWLINE# #INDENT# if ( not is_merge ) : #NEWLINE# #INDENT# campaign = campaigns . campaign_for_user ( user ) #NEWLINE# if campaign : #NEWLINE# #INDENT# return redirect ( campaigns . campaign_url_for ( campaign ) ) #NEWLINE# #UNINDENT# if ( ( len ( auth . user . emails ) == 1 ) and ( len ( auth . user . email_verifications ) == 0 ) ) : #NEWLINE# #INDENT# status . push_status_message ( language . WELCOME_MESSAGE , kind = 'default' , jumbotron = True , trust = True ) #NEWLINE# #UNINDENT# if ( token in auth . user . email_verifications ) : #NEWLINE# #INDENT# status . push_status_message ( language . CONFIRM_ALTERNATE_EMAIL_ERROR , kind = 'danger' , trust = True ) #NEWLINE# #UNINDENT# return redirect ( web_url_for ( 'index' ) ) #NEWLINE# #UNINDENT# status . push_status_message ( language . MERGE_COMPLETE , kind = 'success' , trust = False ) #NEWLINE# return redirect ( web_url_for ( 'user_account' ) ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# user . confirm_email ( token , merge = is_merge ) #NEWLINE# #UNINDENT# except exceptions . EmailConfirmTokenError as e : #NEWLINE# #INDENT# raise HTTPError ( http . BAD_REQUEST , data = { #NEWLINE# #INDENT# 'message_short' : e . message_short , #NEWLINE# 'message_long' : e . message_long , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# if is_initial_confirmation : #NEWLINE# #INDENT# user . date_last_login = datetime . datetime . utcnow ( ) #NEWLINE# user . save ( ) #NEWLINE# mails . send_mail ( to_addr = user . username , mail = mails . WELCOME , mimetype = 'html' , user = user ) #NEWLINE# #UNINDENT# user . verification_key = security . random_string ( 20 ) #NEWLINE# user . save ( ) #NEWLINE# return redirect ( cas . get_login_url ( request . url , auto = True , username = user . username , verification_key = auth . verification_key ) )