Added the activation template, and completed the registration/activation process.
This commit is contained in:
parent
9909eeab36
commit
9c73b32de1
@ -23,6 +23,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import string
|
import string
|
||||||
import random
|
import random
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from scribeengine.lib.base import *
|
from scribeengine.lib.base import *
|
||||||
from scribeengine.lib.validation.client import JSString, JSEmail
|
from scribeengine.lib.validation.client import JSString, JSEmail
|
||||||
@ -47,7 +48,7 @@ class AdminController(BaseController):
|
|||||||
return {
|
return {
|
||||||
u'email': JSEmail(required=True, message=u'You haven\'t typed in an e-mail address.'),
|
u'email': JSEmail(required=True, message=u'You haven\'t typed in an e-mail address.'),
|
||||||
u'password': JSString(required=True, message=u'You haven\'t typed in a password.'),
|
u'password': JSString(required=True, message=u'You haven\'t typed in a password.'),
|
||||||
u'confirm-password': JSString(required=True, equalTo=u'password', message=u'Your passwords don\'t match.')
|
u'confirm-password': JSString(required=True, equalTo=u'#password', message=u'Your passwords don\'t match.')
|
||||||
}
|
}
|
||||||
|
|
||||||
def register_schema(self):
|
def register_schema(self):
|
||||||
@ -67,6 +68,26 @@ class AdminController(BaseController):
|
|||||||
)
|
)
|
||||||
Session.add(user)
|
Session.add(user)
|
||||||
Session.commit()
|
Session.commit()
|
||||||
|
blog_mail = Session.query(Variable).get(u'blog mail')
|
||||||
|
blog_title = Session.query(Variable).get(u'blog title')
|
||||||
|
blog_host = Session.query(Variable).get(u'blog host')
|
||||||
|
if not blog_host:
|
||||||
|
url = u'%s://%s' % (request.environ[u'wsgi.url_scheme'],
|
||||||
|
request.environ[u'HTTP_HOST'])
|
||||||
|
blog_host = Variable(key=u'blog host', value=url)
|
||||||
|
Session.add(blog_host)
|
||||||
|
Session.commit()
|
||||||
|
utils.send_mail(u'/email/activate.mako', u'%s <%s>' % (user.nick, user.email),
|
||||||
|
u'%s <%s>' % (blog_mail.value, blog_title.value),
|
||||||
|
u'[%s] Activate your account!' % blog_title.value,
|
||||||
|
{
|
||||||
|
'user': user,
|
||||||
|
'blog_title': blog_title.value,
|
||||||
|
'blog_host': blog_host.value
|
||||||
|
})
|
||||||
|
h.flash.set_message(u'An e-mail has been sent to your e-mail address. '
|
||||||
|
u'Please activate your account by clicking on the link in your '
|
||||||
|
u'e-mail.', u'success')
|
||||||
h.redirect_to('/')
|
h.redirect_to('/')
|
||||||
|
|
||||||
def activate(self, id=None):
|
def activate(self, id=None):
|
||||||
@ -79,8 +100,8 @@ class AdminController(BaseController):
|
|||||||
h.flash.set_message(u'Your username was missing or incorrect. '
|
h.flash.set_message(u'Your username was missing or incorrect. '
|
||||||
u'Please check your activation e-mail.', u'error')
|
u'Please check your activation e-mail.', u'error')
|
||||||
h.redirect_to(h.url_for(action=u'register'))
|
h.redirect_to(h.url_for(action=u'register'))
|
||||||
user = Session.get(User)\
|
user = Session.query(User)\
|
||||||
.filter_by(email=id)\
|
.filter_by(id=id)\
|
||||||
.filter_by(activation_key=activation_code)\
|
.filter_by(activation_key=activation_code)\
|
||||||
.first()
|
.first()
|
||||||
if not user:
|
if not user:
|
||||||
@ -88,9 +109,13 @@ class AdminController(BaseController):
|
|||||||
u'incorrect. Please check your activation e-mail.', u'error')
|
u'incorrect. Please check your activation e-mail.', u'error')
|
||||||
h.redirect_to(h.url_for(action=u'register'))
|
h.redirect_to(h.url_for(action=u'register'))
|
||||||
user.activation_key = None
|
user.activation_key = None
|
||||||
|
user.modified = datetime.now()
|
||||||
Session.add(user)
|
Session.add(user)
|
||||||
Session.commit()
|
Session.commit()
|
||||||
return render(u'/admin/activate.mako')
|
h.flash.set_message(u'Your account has been activated! Please log in '
|
||||||
|
u'with your e-mail address and the password you typed in during '
|
||||||
|
u'registration.', u'success')
|
||||||
|
h.redirect_to(h.url_for(action=u'login'))
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
c.page_title = u'Login'
|
c.page_title = u'Login'
|
||||||
|
@ -27,10 +27,10 @@ import string
|
|||||||
from random import choice
|
from random import choice
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from pylons import config
|
from pylons import config, c
|
||||||
from turbomail import Message
|
from turbomail import Message
|
||||||
|
|
||||||
from scribeengine.lib.base import render, c
|
from scribeengine.lib.base import render
|
||||||
|
|
||||||
def send_mail(template, mail_to, mail_from, subject, variables={}, attachments=[]):
|
def send_mail(template, mail_to, mail_from, subject, variables={}, attachments=[]):
|
||||||
"""
|
"""
|
||||||
|
21
scribeengine/templates/email/activate.mako
Normal file
21
scribeengine/templates/email/activate.mako
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
Dear ${c.user.nick},
|
||||||
|
|
||||||
|
You have just registered on ${c.blog_title}, but before you continue, you will
|
||||||
|
need to activate your account. You can do this by simply clicking on the link
|
||||||
|
below, or copying and pasting it into your browser.
|
||||||
|
|
||||||
|
${c.blog_host}${h.url_for(controller=u'admin', action=u'activate', id=c.user.id, code=c.user.activation_key)}
|
||||||
|
|
||||||
|
If this is not you, simply leave this e-mail, and the account will expire after
|
||||||
|
72 hours. If you left this e-mail for too long and want to continue with the
|
||||||
|
registration process, click on the link below, type in your e-mail addres, and
|
||||||
|
another e-mail will be sent to you to activate your account.
|
||||||
|
|
||||||
|
${c.blog_host}${h.url_for(controller=u'admin', action=u'reset', id=c.user.id)}
|
||||||
|
|
||||||
|
Once you have completed the registration process you will be able to comment on
|
||||||
|
the posts on the site.
|
||||||
|
|
||||||
|
Kind regards,
|
||||||
|
|
||||||
|
${c.blog_title} Team
|
Reference in New Issue
Block a user