
Untitled
By: a guest on
Jun 21st, 2012 | syntax:
None | size: 1.64 KB | hits: 30 | expires: Never
import logging
from pylons import request, response, session, tmpl_context as c, url
from pylons.controllers.util import abort, redirect
from simplesite.lib.base import BaseController, render
import simplesite.lib.helpers as h
from authkit.authorize.pylons_adaptors import authorize
from authkit.users.sqlalchemy_driver import UsersFromDatabase
from simplesite.model import meta
from pylons import request
import formencode
from formencode import htmlfill
log = logging.getLogger(__name__)
class AccountController(BaseController):
def signin(self):
if not request.environ.get('REMOTE_USER'):
# This triggers the AuthKit middleware into displaying the sign-in form
abort(401)
else:
return render('/derived/account/signedin.html')
def signout(self):
# The actual removal of the AuthKit cookie occurs when the response passes
# through the AuthKit middleware, we simply need to display a page
# confirming the user is signed out
return render('/derived/account/signedout.html')
def signinagain(self):
request.environ['paste.auth_tkt.logout_user']()
return render('/derived/account/signin.html').replace('%s', h.url('signin'))
@authorize(h.auth.has_delete_role)
def register_form(self):
return render('/derived/account/register.html')
def register(self):
users = request.environ['authkit.users']
users.user_create(self.form_result['username'], password=self.form_result['password'])
meta.Session.commit()
return render('/derived/account/register.html')