@must_be_logged_in
def unconfirmed_email_add(auth=None):
 user = auth.user
 json_body = request.get_json()
 try:
  token = json_body['token']
 except KeyError:
  raise HTTPError(http.BAD_REQUEST, data={'message_short': 'Missing token', 'message_long': 'Must provide a token'})
 try:
  user.confirm_email(token, merge=True)
 except exceptions.InvalidTokenError:
  raise InvalidTokenError(http.BAD_REQUEST, data={'message_short': 'Invalid user token', 'message_long': 'The user token is invalid'})
 except exceptions.EmailConfirmTokenError as e:
  raise HTTPError(http.BAD_REQUEST, data={'message_short': e.message_short, 'message_long': e.message_long})
 user.save()
 return ({'status': 'success', 'removed_email': json_body['address']}, 200)

@ must_be_logged_in def unconfirmed_email_add ( auth = None ) : user = auth . user json_body = request . get_json ( ) try : token = json_body [ 'token' ] except KeyError : raise HTTPError ( http . BAD_REQUEST , data = { 'message_short' : 'Missing token' , 'message_long' : 'Must provide a token' } ) try : user . confirm_email ( token , merge = True ) except exceptions . InvalidTokenError : raise InvalidTokenError ( http . BAD_REQUEST , data = { 'message_short' : 'Invalid user token' , 'message_long' : 'The user token is invalid' } ) except exceptions . EmailConfirmTokenError as e : raise HTTPError ( http . BAD_REQUEST , data = { 'message_short' : e . message_short , 'message_long' : e . message_long } ) user . save ( ) return ( { 'status' : 'success' , 'removed_email' : json_body [ 'address' ] } , 200 )
called at login if user confirms their merge or email add .