Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
2797 Lượt xem

I want when user change new password, have to enter current password.

 So I created 'confirm_password' field to check the password which the users enter correct with the password in login.


this is my code. But it not working.
Please help me...

def check_password(self, id, password):
​user= (
​request.env["res.users"]           
​​.sudo()           
​.search([("id", "=", id), ("password", "=", password)], limit=1)       
​)
​if user:
​return user
​else:
raiseSomethingWentWrong()
def change_new_password(self, id, password, new_password):
​user=self.check_password(id, password)
​if user:
​result=user.sudo().write({"password": new_password})
​if result:
​return result
​else:
​raise CannotUpdatePassword()
​else:
​raise SomethingWentWrong()


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

Please refer to this app; it may help you.

https://apps.odoo.com/apps/modules/16.0/password_reset_manager/

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Thanks for your help.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

There's a method in the res.users​ model called _check_credentials​ - check it out. You could use it directly for a specific user. Also I saw there a function called change_password​ and supposedly it does what you want - checks that the old password is the right one and after that changes it with the new one.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 25
1597
1
thg 11 23
1806
0
thg 11 23
1570
1
thg 5 23
2569
4
thg 8 22
119394