2008-06-03 22:24:32 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import logging
|
|
|
|
|
|
|
|
from gnuviechadminweb.lib.base import *
|
2008-06-05 20:25:08 +02:00
|
|
|
from authkit.permissions import ValidAuthKitUser
|
|
|
|
from authkit.authorize.pylons_adaptors import authorize
|
2008-06-03 22:24:32 +02:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
class GvaController(BaseController):
|
|
|
|
def index(self):
|
|
|
|
# Return a rendered template
|
|
|
|
return render('/main.mako')
|
2008-06-05 20:25:08 +02:00
|
|
|
|
|
|
|
@authorize(ValidAuthKitUser())
|
|
|
|
def password(self):
|
|
|
|
return render('/chpassword.mako')
|
|
|
|
|
|
|
|
@authorize(ValidAuthKitUser())
|
|
|
|
def updatepassword(self):
|
|
|
|
users = request.environ['authkit.users']
|
|
|
|
if users.user_has_password(request.environ['REMOTE_USER'],
|
|
|
|
request.params['oldpassword']):
|
|
|
|
if request.params['password'] != request.params['confirm']:
|
|
|
|
c.messages['errors'].append("New password and confirmation don't match")
|
|
|
|
elif len(request.params['password']) < 8:
|
|
|
|
c.messages['errors'].append("Your new password is too short. It must consist of at least 8 characters")
|
|
|
|
else:
|
|
|
|
users.user_set_password(request.environ['REMOTE_USER'],
|
|
|
|
request.params['password'])
|
|
|
|
c.messages['messages'].append("Your password has been changed.")
|
|
|
|
else:
|
|
|
|
c.messages['errors'].append("Your old password is not correct.")
|
|
|
|
if c.messages['errors']:
|
|
|
|
return render('/chpassword.mako')
|
|
|
|
return render('/main.mako')
|