def confirm_email(token):
 (expired, invalid, user) = confirm_email_token_status(token)
 if ((not user) or invalid):
  invalid = True
  do_flash(*get_message('INVALID_CONFIRMATION_TOKEN'))
 if expired:
  send_confirmation_instructions(user)
  do_flash(*get_message('CONFIRMATION_EXPIRED', email=user.email, within=_security.confirm_email_within))
 if (invalid or expired):
  return redirect((get_url(_security.confirm_error_view) or url_for('send_confirmation')))
 if (user != current_user):
  logout_user()
  login_user(user)
 if confirm_user(user):
  after_this_request(_commit)
  msg = 'EMAIL_CONFIRMED'
 else:
  msg = 'ALREADY_CONFIRMED'
 do_flash(*get_message(msg))
 return redirect((get_url(_security.post_confirm_view) or get_url(_security.post_login_view)))

def confirm_email ( token ) : ( expired , invalid , user ) = confirm_email_token_status ( token ) if ( ( not user ) or invalid ) : invalid = True do_flash ( * get_message ( 'INVALID_CONFIRMATION_TOKEN' ) ) if expired : send_confirmation_instructions ( user ) do_flash ( * get_message ( 'CONFIRMATION_EXPIRED' , email = user . email , within = _security . confirm_email_within ) ) if ( invalid or expired ) : return redirect ( ( get_url ( _security . confirm_error_view ) or url_for ( 'send_confirmation' ) ) ) if ( user != current_user ) : logout_user ( ) login_user ( user ) if confirm_user ( user ) : after_this_request ( _commit ) msg = 'EMAIL_CONFIRMED' else : msg = 'ALREADY_CONFIRMED' do_flash ( * get_message ( msg ) ) return redirect ( ( get_url ( _security . post_confirm_view ) or get_url ( _security . post_login_view ) ) )
view function which handles a email confirmation request .