#NEWLINE# @ must_be_logged_in #NEWLINE# def twofactor_enable( auth , * args , **kwargs ) : #NEWLINE# #INDENT# user = auth . user #NEWLINE# if user . has_addon ( 'twofactor' ) : #NEWLINE# #INDENT# return HTTPError ( http . BAD_REQUEST , data = dict ( message_long = 'This user already has two-factor enabled' ) ) #NEWLINE# #UNINDENT# user . add_addon ( 'twofactor' , auth = auth ) #NEWLINE# user_addon = user . get_addon ( 'twofactor' ) #NEWLINE# user_addon . save ( ) #NEWLINE# user . save ( ) #NEWLINE# return { #NEWLINE# #INDENT# 'result' : serialize_settings ( auth ) , #NEWLINE# #UNINDENT# }