跳至內容
選單
此問題已被標幟
1767 瀏覽次數

Hola, 

I am facing an issue that makes me stucked.

I want to add a field 'Actual password' in reset form in Odoo and i  want to verify that the password given matchs the old one. my question is : how to get the value of the actual password of the user which we want to reset the password and compare it to the given one in the form (validation process) ?

What i did is ovveriding the 'do_signup' method in controller 'AuthSignupHome' and add a condition that does not work!

Here is my code : 

in my controller i inherited the method 'do_signup' and add few lines:

class AuthSignupHome(AuthSignupHome):
def do_signup(self, qcontext):
    """ Shared helper that creates a res.partner out of a token """
    values = {key: qcontext.get(key) for key in ('login', 'name', 'password')}
    if not values:
    raise UserError(_("The form was not properly filled in."))
    if values.get('password') != qcontext.get('confirm_password'):
    raise UserError(_("Passwords do not match; please retype them."))
  

*usr = request.env['res.users'].sudo().search(['login','=',values.get('login')])
*cr=request.env.cr
*passwd=cr.execute("select password from res_users where id=%s",usr)
*if qcontext.get('old_password') != passwd:
        *raise UserError(_("Password incorrect!"))
   supported_langs = [lang['code'] for lang in request.env['res.lang'].sudo().search_read([],     ['code'])]
    if request.lang in supported_langs:
    values['lang'] = request.lang
    self._signup_with_values(qcontext.get('token'), values)
    request.env.cr.commit()
* lines added by me


   Any help please!!

頭像
捨棄
作者

Any help.. still stucked!!!