Re: [web2py] Re: auth.messages.verify_email html template

2018-02-03 Thread Yi Liu
For other people's reference, I ended up modifying gluon/tools.py. It is 
probably not a good practise. But it is the easiest solution.

I edit register() and email_reset_password()

modifying something like (depends on which one)

message=self.messages.verify_email  % d

to

message=('',response.render('email/template.html', d:

it is important to use a 2-tuple or 2-list to pass the second item to html 
in the email, the empty '' will go to text. Otherwise, it will likely be 
send as plain text, especially if you have 
> Hi Jay Martin. Actually, I ended up coding my own functions instead of 
> instantiating the Auth class. That is, I coded my own login, register, 
> reset_password, etc functions.
>
> For example, for the login, this is the code in the controller:
>
> # This code should run when the users posts the form with all required 
> data, and after doing some validation to the data provided
> from gluon.tools import web2py_uuid
> registration_key = web2py_uuid()
> db.auth_user.insert(\
> first_name=form.vars.first_name, \ 
> last_name=form.vars.last_name, \
> email=form.vars.email, \
> password=db.auth_user.password.validate(form.vars.password)[0], \
> registration_key=registration_key)
> mail.send(to=form.vars.email, subject='Confirm your registration', \
>   message='Hi %s, thanks for registering in our website!\n\n' %first_name 
> + \
> 'To finish the registration, please click on the next link:\n' + \
> '%s\n\n' %URL('default', 'user/verify_email/%s' %registration_key, 
> host=request.env.http_host))
>
>
> Then, in the default/user/verify_email I use this code:
>
> registration_key = request.args(1)
> user = db(db.auth_user.registration_key==registration_key
> ).select().first()
> if not user:
> redirect(URL('default', 'index'))
> user.update_record(registration_key='')
> auth.login_user(user)
> session.flash = 'Your registration has been confirmed. Thanks!'
> redirect(URL('init', 'default', 'index'))
>
>
> I hope it helps!
>
>
>
>
>
> El sábado, 22 de noviembre de 2014 10:39:12 UTC-3, Jay Martin escribió:
>>
>> @Lisandro, would happen to have these code snippets handy to share? I'm 
>> interested in using the mailgun api too. Either way, thanks for checking!
>>
>> My best,
>> Jay
>>
>> On Tuesday, October 29, 2013 5:46:51 PM UTC-4, Lisandro wrote:
>>>
>>>  ...
>>>
>>> For those interested in doing that, is just as simple as instantiating 
>>> Auth class and overwriting wanted methods, for example, I overwrited 
>>> "register" and "email_reset_password" methods in Auth class, that is, to 
>>> send my custom emails on register and request reset password respectively.
>>>
>>> Regards, Lisandro.
>>>
>>>
>>>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: auth.messages.verify_email html template

2018-02-02 Thread Yi Liu
Thanks for sharing. I really hope web2py can officially update the native 
function to allow modern html email for verification. I understand the 
contributors have priorities.

Yi

On Saturday, November 22, 2014 at 5:56:06 AM UTC-8, Lisandro wrote:
>
> Hi Jay Martin. Actually, I ended up coding my own functions instead of 
> instantiating the Auth class. That is, I coded my own login, register, 
> reset_password, etc functions.
>
> For example, for the login, this is the code in the controller:
>
> # This code should run when the users posts the form with all required 
> data, and after doing some validation to the data provided
> from gluon.tools import web2py_uuid
> registration_key = web2py_uuid()
> db.auth_user.insert(\
> first_name=form.vars.first_name, \ 
> last_name=form.vars.last_name, \
> email=form.vars.email, \
> password=db.auth_user.password.validate(form.vars.password)[0], \
> registration_key=registration_key)
> mail.send(to=form.vars.email, subject='Confirm your registration', \
>   message='Hi %s, thanks for registering in our website!\n\n' %first_name 
> + \
> 'To finish the registration, please click on the next link:\n' + \
> '%s\n\n' %URL('default', 'user/verify_email/%s' %registration_key, 
> host=request.env.http_host))
>
>
> Then, in the default/user/verify_email I use this code:
>
> registration_key = request.args(1)
> user = db(db.auth_user.registration_key==registration_key
> ).select().first()
> if not user:
> redirect(URL('default', 'index'))
> user.update_record(registration_key='')
> auth.login_user(user)
> session.flash = 'Your registration has been confirmed. Thanks!'
> redirect(URL('init', 'default', 'index'))
>
>
> I hope it helps!
>
>
>
>
>
> El sábado, 22 de noviembre de 2014 10:39:12 UTC-3, Jay Martin escribió:
>>
>> @Lisandro, would happen to have these code snippets handy to share? I'm 
>> interested in using the mailgun api too. Either way, thanks for checking!
>>
>> My best,
>> Jay
>>
>> On Tuesday, October 29, 2013 5:46:51 PM UTC-4, Lisandro wrote:
>>>
>>>  ...
>>>
>>> For those interested in doing that, is just as simple as instantiating 
>>> Auth class and overwriting wanted methods, for example, I overwrited 
>>> "register" and "email_reset_password" methods in Auth class, that is, to 
>>> send my custom emails on register and request reset password respectively.
>>>
>>> Regards, Lisandro.
>>>
>>>
>>>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: auth.messages.verify_email html template

2014-11-22 Thread Jay Martin
@Lisandro, would happen to have these code snippets handy to share? I'm 
interested in using the mailgun api too. Either way, thanks for checking!

My best,
Jay

On Tuesday, October 29, 2013 5:46:51 PM UTC-4, Lisandro wrote:

  ...

 For those interested in doing that, is just as simple as instantiating 
 Auth class and overwriting wanted methods, for example, I overwrited 
 register and email_reset_password methods in Auth class, that is, to 
 send my custom emails on register and request reset password respectively.

 Regards, Lisandro.




-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: auth.messages.verify_email html template

2014-11-22 Thread Lisandro
Hi Jay Martin. Actually, I ended up coding my own functions instead of 
instantiating the Auth class. That is, I coded my own login, register, 
reset_password, etc functions.

For example, for the login, this is the code in the controller:

# This code should run when the users posts the form with all required 
data, and after doing some validation to the data provided
from gluon.tools import web2py_uuid
registration_key = web2py_uuid()
db.auth_user.insert(\
first_name=form.vars.first_name, \ 
last_name=form.vars.last_name, \
email=form.vars.email, \
password=db.auth_user.password.validate(form.vars.password)[0], \
registration_key=registration_key)
mail.send(to=form.vars.email, subject='Confirm your registration', \
  message='Hi %s, thanks for registering in our website!\n\n' %first_name + 
\
'To finish the registration, please click on the next link:\n' + \
'%s\n\n' %URL('default', 'user/verify_email/%s' %registration_key, host=
request.env.http_host))


Then, in the default/user/verify_email I use this code:

registration_key = request.args(1)
user = db(db.auth_user.registration_key==registration_key).select().first()
if not user:
redirect(URL('default', 'index'))
user.update_record(registration_key='')
auth.login_user(user)
session.flash = 'Your registration has been confirmed. Thanks!'
redirect(URL('init', 'default', 'index'))


I hope it helps!





El sábado, 22 de noviembre de 2014 10:39:12 UTC-3, Jay Martin escribió:

 @Lisandro, would happen to have these code snippets handy to share? I'm 
 interested in using the mailgun api too. Either way, thanks for checking!

 My best,
 Jay

 On Tuesday, October 29, 2013 5:46:51 PM UTC-4, Lisandro wrote:

  ...

 For those interested in doing that, is just as simple as instantiating 
 Auth class and overwriting wanted methods, for example, I overwrited 
 register and email_reset_password methods in Auth class, that is, to 
 send my custom emails on register and request reset password respectively.

 Regards, Lisandro.




-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: auth.messages.verify_email html template

2014-11-22 Thread Jay Martin
Extremely helpful! Thanks Lisandro. I'll be sure to share any tweaks...

On Saturday, November 22, 2014 8:56:06 AM UTC-5, Lisandro wrote:

 ...

 I hope it helps!


-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: auth.messages.verify_email html template

2013-10-29 Thread Lisandro Rostagno
Thanks for the tip! I thought it would be more difficult, but apparently
nothing is too difficult with web2py ;)

For those interested in doing that, is just as simple as instantiating Auth
class and overwriting wanted methods, for example, I overwrited register
and email_reset_password methods in Auth class, that is, to send my
custom emails on register and request reset password respectively.

Regards, Lisandro.


2013/10/27 Ykä Marjanen yka.marja...@gmail.com

 I have replaced the standard verification with my own. The standard
 authentication is pretty simple as it creates a unique key, which it stores
 in the database and sends as a link to the registrant. When the link is
 clicked it will match the registration details with the unique id and
 stores (accepts the user) them.

 This way you can customize the template and use email API (json), which is
 much more powerful than smtp method (I use mailgun).

 Ykä

 --
 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 a topic in the
 Google Groups web2py-users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/web2py/NbLduKZR_4k/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 web2py+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.