##// END OF EJS Templates
html fix
html fix

File last commit:

r202:3fd2af1b default
r208:c674d994 default
Show More
login.py
42 lines | 1.4 KiB | text/x-python | PythonLexer
fixed menu in home page, and added login html with forms that validates username and password.
r186 import logging
from formencode import htmlfill
from pylons import request, response, session, tmpl_context as c, url
from pylons.controllers.util import abort, redirect
from pylons_app.lib.base import BaseController, render
import formencode
from pylons_app.model.forms import LoginForm
from pylons_app.lib.auth import AuthUser
log = logging.getLogger(__name__)
class LoginController(BaseController):
updated logging in logout. Added before, on login page.
r202 def __before__(self):
super(LoginController, self).__before__()
fixed menu in home page, and added login html with forms that validates username and password.
r186 def index(self):
cleared prints leftoovers, and changed current user fetching in login controller
r195 #redirect if already logged in
if c.hg_app_user.is_authenticated:
fixed menu in home page, and added login html with forms that validates username and password.
r186 return redirect(url('hg_home'))
if request.POST:
#import Login Form validator class
login_form = LoginForm()
try:
c.form_result = login_form.to_python(dict(request.POST))
return redirect(url('hg_home'))
except formencode.Invalid as errors:
c.form_errors = errors.error_dict
return htmlfill.render(
render('/login.html'),
defaults=errors.value,
encoding="UTF-8")
return render('/login.html')
def logout(self):
session['hg_app_user'] = AuthUser()
session.save()
updated logging in logout. Added before, on login page.
r202 log.info('Logging out and setting user as Empty')
fixed menu in home page, and added login html with forms that validates username and password.
r186 redirect(url('hg_home'))