#NEWLINE# def user_update( request , user , **data ) : #NEWLINE# #INDENT# manager = keystoneclient ( request , admin = True ) . users #NEWLINE# error = None #NEWLINE# if ( not keystone_can_edit_user ( ) ) : #NEWLINE# #INDENT# raise keystone_exceptions . ClientException ( 405 , _ ( 'Identity service does not allow editing user data.' ) ) #NEWLINE# #UNINDENT# if ( VERSIONS . active < 3 ) : #NEWLINE# #INDENT# password = data . pop ( 'password' ) #NEWLINE# project = data . pop ( 'project' ) #NEWLINE# try : #NEWLINE# #INDENT# user = manager . update ( user , ** data ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# error = exceptions . handle ( request , ignore = True ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# user_update_tenant ( request , user , project ) #NEWLINE# user . tenantId = project #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# error = exceptions . handle ( request , ignore = True ) #NEWLINE# #UNINDENT# user_roles = roles_for_user ( request , user , project ) #NEWLINE# if ( not user_roles ) : #NEWLINE# #INDENT# messages . warning ( request , ( _ ( 'User %s has no role defined for that project.' ) % data . get ( 'name' , None ) ) ) #NEWLINE# #UNINDENT# if password : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# user_update_password ( request , user , password ) #NEWLINE# if ( user . id == request . user . id ) : #NEWLINE# #INDENT# return utils . logout_with_message ( request , _ ( 'Password changed. Please log in again to continue.' ) ) #NEWLINE# #UNINDENT# #UNINDENT# except Exception : #NEWLINE# #INDENT# error = exceptions . handle ( request , ignore = True ) #NEWLINE# #UNINDENT# #UNINDENT# if ( error is not None ) : #NEWLINE# #INDENT# raise error #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( not data [ 'password' ] ) : #NEWLINE# #INDENT# data . pop ( 'password' ) #NEWLINE# #UNINDENT# user = manager . update ( user , ** data ) #NEWLINE# if ( data . get ( 'password' ) and ( user . id == request . user . id ) ) : #NEWLINE# #INDENT# return utils . logout_with_message ( request , _ ( 'Password changed. Please log in again to continue.' ) ) #NEWLINE# #UNINDENT# #UNINDENT# return VERSIONS . upgrade_v2_user ( user )