Alternately, simply remove line 3628 of gluon/tools.py
table_user['email'].writable = False
On Friday, December 14, 2018 at 10:25:10 AM UTC-6, Leonel Câmara wrote:
>
> I think this problem was caused by CAS, but there were other problems,
> namely that it would not check the new email again if it required
> verification. Anyway you can have my function.
>
> def change_email():
> from gluon.utils import web2py_uuid
> from gluon.tools import replace_id
> table_user = auth.table_user()
> if not auth.is_logged_in():
> redirect(auth.settings.login_url,
> client_side=auth.settings.client_side)
> next = auth.get_vars_next()
> form = SQLFORM.factory(table_user.email)
> if form.accepts(request, session, formname='change_email', hideerror=
> auth.settings.hideerror):
> key = web2py_uuid()
> if auth.settings.registration_requires_verification:
> key = 'pending-' + key
> link = auth.url(
> auth.settings.function, args=('verify_email', key), scheme
> =True)
> table_user[auth.user_id].update_record(email=form.vars.email,
> key=key)
> auth.user.update(table_user._filter_fields(form.vars))
> d = dict(auth.user)
> d.update(dict(key=key, link=link, firstname=auth.user.
> first_name, lastname=auth.user.last_name, username=form.vars.email))
> if not (auth.settings.mailer and auth.settings.mailer.send(
> to=form.vars.email,
> subject=auth.messages.verify_email_subject,
> message=auth.messages.verify_email % d)):
> auth.db.rollback()
> response.flash = auth.messages.unable_send_email
> return form
> session.flash = auth.messages.email_sent
> if not next:
> next = URL(args=request.args)
> else:
> next = replace_id(next, form)
> redirect(next, client_side=auth.settings.client_side)
> return form
>
> You can just stick it inside the user function in the default controller
> and then before return dict(form=auth()) put something like:
>
>
> if request.args(0) == 'change_email':
> return dict(form=change_email())
>
> Finally add a link to change the email in the user.html view when you're
> editing the profile:
>
> {{
> if request.args(0) == 'profile':
> form.element(_id='auth_user_email__row').append(A(I(_class='fa
> fa-pencil'), _href=URL(c='default', f='user', args=['change_email'], vars
> ={'_next': URL(c='default', f='user', args=['profile'])}), _class="ml-1"))
> pass
> }}
>
>
> put that before the {{=form}}
>
>
>
>
>
--
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/d/optout.