def login(): from uliweb.contrib.auth import authenticate, login from forms import LoginForm from uliweb.form import Submit, Tag LoginForm.form_buttons = [Submit(value=_('Login'), _class="button")] form = LoginForm() if request.method == 'GET': form.next.data = request.GET.get('next', '/') return {'form':form, 'msg':''} if request.method == 'POST': flag = form.validate(request.params) if flag: f, d = authenticate(username=form.username.data, password=form.password.data) if f: request.session.remember = form.rememberme.data login(form.username.data) next = request.POST.get('next', '/') return redirect(next) else: data = d msg = form.errors.get('_', '') or _('Login failed!') return {'form':form, 'msg':str(msg)}
def login(): from uliweb.contrib.auth import authenticate, login form = functions.get_form('auth.LoginForm')() if request.method == 'GET': form.next.data = request.GET.get('next', request.referrer or '/') return {'form':form, 'msg':''} if request.method == 'POST': flag = form.validate(request.params) if flag: f, d = authenticate(username=form.username.data, password=form.password.data) if f: request.session.remember = form.rememberme.data login(form.username.data) next = urllib.unquote(request.POST.get('next', '/')) return redirect(next) else: data = d msg = form.errors.get('_', '') or _('Login failed!') return {'form':form, 'msg':str(msg)}
def login(): from uliweb.contrib.auth import authenticate, login form = functions.get_form('auth.LoginForm')() if request.method == 'GET': form.next.data = request.GET.get('next', request.referrer or '/') return {'form': form, 'msg': ''} if request.method == 'POST': flag = form.validate(request.params) if flag: f, d = authenticate(username=form.username.data, password=form.password.data) if f: request.session.remember = form.rememberme.data login(form.username.data) next = urllib.unquote(request.POST.get('next', '/')) return redirect(next) else: data = d msg = form.errors.get('_', '') or _('Login failed!') return {'form': form, 'msg': str(msg)}