'Update account password.
Called by /prefs/update on the site. For frontend form verification
purposes, `newpass` and `verpass` must be equal for a password change
to succeed.'

@validatedForm(VUser(), VModhash(), VVerifyPassword('curpass', fatal=False), password=VPasswordChange(['newpass', 'verpass']), invalidate_oauth=VBoolean('invalidate_oauth'))
def POST_update_password(self, form, jquery, password, invalidate_oauth):

    if form.has_errors('curpass', errors.WRONG_PASSWORD):
        return
    if (password and (not (form.has_errors('newpass', errors.BAD_PASSWORD) or form.has_errors('verpass', errors.BAD_PASSWORD_MATCH)))):
        if invalidate_oauth:
            self.revoke_sessions(c.user)
        change_password(c.user, password)
        if c.user.email:
            emailer.password_change_email(c.user)
        form.set_text('.status', _('your    password    has    been    updated'))
        form.set_inputs(curpass='', newpass='', verpass='')
        self.login(c.user)
