Added activate method.
This commit is contained in:
parent
0797f5799c
commit
9909eeab36
@ -69,6 +69,29 @@ class AdminController(BaseController):
|
||||
Session.commit()
|
||||
h.redirect_to('/')
|
||||
|
||||
def activate(self, id=None):
|
||||
activation_code = request.GET.get('code')
|
||||
if not activation_code:
|
||||
h.flash.set_message(u'Your activation code was missing or '
|
||||
u'incorrect. Please check your activation e-mail.', u'error')
|
||||
h.redirect_to(h.url_for(action=u'register'))
|
||||
if not id:
|
||||
h.flash.set_message(u'Your username was missing or incorrect. '
|
||||
u'Please check your activation e-mail.', u'error')
|
||||
h.redirect_to(h.url_for(action=u'register'))
|
||||
user = Session.get(User)\
|
||||
.filter_by(email=id)\
|
||||
.filter_by(activation_key=activation_code)\
|
||||
.first()
|
||||
if not user:
|
||||
h.flash.set_message(u'Your username or activation code is '
|
||||
u'incorrect. Please check your activation e-mail.', u'error')
|
||||
h.redirect_to(h.url_for(action=u'register'))
|
||||
user.activation_key = None
|
||||
Session.add(user)
|
||||
Session.commit()
|
||||
return render(u'/admin/activate.mako')
|
||||
|
||||
def login(self):
|
||||
c.page_title = u'Login'
|
||||
return render(u'/admin/login.mako')
|
||||
|
Reference in New Issue
Block a user