I made myself with the solution....
In the controller I've only put the form, but I've added onvalidation,
onaccept and next parameters to achieved what I want.
@auth.requires_membership('regular_user')
def password_change():
form = auth.change_password(onvalidation=validate_pwd,
onaccept=change_user_state, next=URL('step2'))
return dict(form=form)
def validate_pwd(form):
if form.vars.old_password == form.vars.new_password:
form.errors.new_password = T("The New password must be different
than the old one!")
def change_user_state(self):
reg = db.regular_user(db.regular_user.ruid==auth.user.id)
reg.state = 'step2'
reg.update_record()
Thanks anyway!!! I hope this is good for someone.
2014-02-13 9:08 GMT-03:00 Leandro E. Colombo Viña <[email protected]>
:
> Hi guys!
>
> I've got a problem trying to build a form for changing password. Here is
> my controller:
>
> @auth.requires_membership('regular_user')
> def password_change():
> form = auth.change_password(next=URL('step2'))
> if form.process().accepted:
> reg = db.regular_user(db.regular_user.ruid==auth.user.id)
> reg.state = 'step2'
> reg.update_record()
> session.flash = "Thanks for updating your password!"
> return dict(form=form)
>
> The view only have {{=form}}.
>
> The form loads, and apparently sends the data but the password on the DB
> isn't get updated. The state of the regular user on the table regular_user
> is changed after the form was sent.
>
> What am I missing???
>
> Thanks in advance!!!
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.