Commit 25d39c8b by aa.gusti

captcha

1 parent 13cc05c7
...@@ -50,7 +50,7 @@ class RegSchema(colander.Schema): ...@@ -50,7 +50,7 @@ class RegSchema(colander.Schema):
colander.String(), colander.String(),
validator=colander.Length(max=18, max_err='Maximum ${max} Digit', validator=colander.Length(max=18, max_err='Maximum ${max} Digit',
min=15, min_err='Minimimum ${min} Digit'), min=15, min_err='Minimimum ${min} Digit'),
title="NIK", title="No.Identitas/NIK",
oid="kode") oid="kode")
detail = NamaSchema() detail = NamaSchema()
captcha = colander.SchemaNode( captcha = colander.SchemaNode(
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<p><img src="${request._host}/static/img/logo.png" class="img-float img-thumbnail"/></p> <p><img src="${request._host}/static/img/logo.png" class="img-float img-thumbnail"/></p>
Anda tidak berhak mengakses halaman ${url}<br> Anda tidak berhak mengakses halaman ${url}<br>
<a href="${request.route_url('home')}">Kembali ke Halaman Utama</a> <a href="${request.referer}">Kembali ke Halaman Sebelumnya</a>
</div> </div>
</body> </body>
......
...@@ -95,7 +95,9 @@ ...@@ -95,7 +95,9 @@
<div metal:fill-slot="scripts"> <div metal:fill-slot="scripts">
<script tal:condition=captcha> <script tal:condition=captcha>
$(document).ready(function () { $(document).ready(function () {
$("#captcha").parent().prepend('<img style="height:30px; width:auto; margin-bottom:5px;" src="/captcha/${captcha}.png">') $("#captcha").parent().prepend(
'<img style="height:30px; width:auto; margin-bottom:5px;" ' +
'src="${home}/captcha/${captcha}.png">')
$('#captcha').on('input', function(evt) { $('#captcha').on('input', function(evt) {
$(this).val(function(_, val) { $(this).val(function(_, val) {
......
...@@ -25,6 +25,7 @@ from importlib import import_module ...@@ -25,6 +25,7 @@ from importlib import import_module
import colander import colander
from deform import widget, Form, ValidationFailure, Button from deform import widget, Form, ValidationFailure, Button
from pyramid.httpexceptions import HTTPFound, HTTPNotFound from pyramid.httpexceptions import HTTPFound, HTTPNotFound
from pyramid.renderers import render_to_response
from pyramid.security import remember, forget from pyramid.security import remember, forget
from pyramid.view import view_config from pyramid.view import view_config
from ziggurat_foundations.models.services.external_identity import ExternalIdentityService from ziggurat_foundations.models.services.external_identity import ExternalIdentityService
...@@ -61,6 +62,7 @@ def get_login_headers(request, user): ...@@ -61,6 +62,7 @@ def get_login_headers(request, user):
@view_config(route_name='login', renderer='templates/login.pt') @view_config(route_name='login', renderer='templates/login.pt')
def view_login(request): def view_login(request):
next_url = request.params.get('next', request.referrer) next_url = request.params.get('next', request.referrer)
login_tpl = get_params('login_tpl', 'templates/login.pt')
if not next_url: if not next_url:
next_url = request.route_url('home') # get_params('_host')+ next_url = request.route_url('home') # get_params('_host')+
...@@ -145,12 +147,16 @@ def view_login(request): ...@@ -145,12 +147,16 @@ def view_login(request):
return redirect_login(request, user) return redirect_login(request, user)
message="" message=""
login="" login=""
return dict(form=form.render(), return render_to_response(login_tpl,
dict(form=form.render(),
message=message, message=message,
url=request.route_url('login'), url=request.route_url('login'),
next_url=next_url, next_url=next_url,
login=login, login=login,),
) request=request)
# return dict(
# )
def redirect_login(request, user): def redirect_login(request, user):
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!