Authentication web2py通过服务呼叫更改密码

Authentication web2py通过服务呼叫更改密码,authentication,web2py,Authentication,Web2py,在web2py中,我想通过xml rpc调用更改密码。我该怎么做 @auth.requires_login() def call(): return service() @service.xmlrpc def change_password(old_pass, new_pass, confirm_pass): #Validate args and then does the following #Borrowed from web2py tools.py source

在web2py中,我想通过xml rpc调用更改密码。我该怎么做

@auth.requires_login()
def call():
    return service()

@service.xmlrpc
def change_password(old_pass, new_pass, confirm_pass):
    #Validate args and then does the following
    #Borrowed from web2py tools.py source
    table_user = auth.settings.table_user 
    passfield = auth.settings.password_field
    s = db(table_user.id == auth.user_id) 
    d = {passfield: new_pass}
    s.update(**d) #this saves new password in plain text; why?? 
    return

默认情况下,password字段使用CRYPT()验证器对密码进行散列。但是,验证程序应用于表单提交(当调用form.accepts()方法时),而不是在常规的.insert()和.update()操作期间。在插入新密码之前,您可以自己通过auth_user.password字段的CRYPT validator传递密码:

d = {passfield: table_user[passfield].validate(new_pass)[0]}
s.update(**d)
更新:更改
需要[-1]
才能
验证

更新:这在当前稳定版本(1.99.3)中不起作用,但在下一版本中,您将能够执行以下操作:

d = {passfield: new_pass}
s.validate_and_update(**d)

validate_和_update
方法已经存在,但以前它只运行验证器检查错误,而不转换提交的值(因此不能使用CRYPT之类的验证器,它转换提交的值)。更新后的版本现在也会转换值,因此应该使用CRYPT。

默认情况下,密码字段使用CRYPT()验证程序对密码进行哈希运算。但是,验证程序应用于表单提交(当调用form.accepts()方法时),而不是在常规的.insert()和.update()操作期间。在插入新密码之前,您可以自己通过auth_user.password字段的CRYPT validator传递密码:

d = {passfield: table_user[passfield].validate(new_pass)[0]}
s.update(**d)
更新:更改
需要[-1]
才能
验证

更新:这在当前稳定版本(1.99.3)中不起作用,但在下一版本中,您将能够执行以下操作:

d = {passfield: new_pass}
s.validate_and_update(**d)
validate_和_update
方法已经存在,但以前它只运行验证器检查错误,而不转换提交的值(因此不能使用CRYPT之类的验证器,它转换提交的值)。更新的版本现在也会转换这些值,因此应该使用CRYPT