#NEWLINE# @ tornado . web . authenticated #NEWLINE# @ gen . coroutine #NEWLINE# def post( self ) : #NEWLINE# #INDENT# self . check_xsrf_cookie ( ) #NEWLINE# upstream_server = self . get_argument ( 'upstream_server' , '' ) #NEWLINE# password = self . get_argument ( 'password' , '' ) #NEWLINE# http_username = self . get_argument ( 'http_username' , '' ) #NEWLINE# http_password = self . get_argument ( 'http_password' , '' ) #NEWLINE# if ( upstream_server and ( not validate_url ( http_username ) ) ) : #NEWLINE# #INDENT# self . set_flash_message ( 'error' , 'Url is not valid.' ) #NEWLINE# self . redirect ( '/__manage' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . api_data . upstream_server = upstream_server #NEWLINE# self . api_data . http_username = http_username #NEWLINE# if password : #NEWLINE# #INDENT# password_hash = ( yield self . application . pool . submit ( bcrypt . hashpw , password , bcrypt . gensalt ( ) ) ) #NEWLINE# self . api_data . password = password_hash #NEWLINE# #UNINDENT# if ( not http_username ) : #NEWLINE# #INDENT# self . api_data . http_password = '' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if http_password : #NEWLINE# #INDENT# http_password_hash = ( yield self . application . pool . submit ( crypt , http_password , gencryptsalt ( ) ) ) #NEWLINE# self . api_data . http_password = http_password_hash #NEWLINE# #UNINDENT# #UNINDENT# self . api_data . save ( ) #NEWLINE# self . set_flash_message ( 'success' , 'Settings has been successfully saved.' ) #NEWLINE# self . redirect ( '/__manage/settings' )