Fixes in session
This commit is contained in:
parent
a525273af2
commit
6a6a63730c
5 changed files with 12 additions and 7 deletions
|
|
@ -32,6 +32,7 @@ class ColorField(IntegerField):
|
|||
|
||||
self.name_form=ColorForm
|
||||
self.jtype='string'
|
||||
self.jexample='#f0f0f0'
|
||||
|
||||
def check(self, value):
|
||||
|
||||
|
|
|
|||
|
|
@ -11,11 +11,15 @@ check_url = re.compile(
|
|||
|
||||
class UrlField(CharField):
|
||||
|
||||
def __init__(self, name, size=1024, required=False):
|
||||
|
||||
super().__init__(name, size, required)
|
||||
self.jformat='url'
|
||||
|
||||
def check(self, value):
|
||||
|
||||
self.error=False
|
||||
self.txt_error=''
|
||||
self.jformat='url'
|
||||
|
||||
if not check_url.match(value):
|
||||
|
||||
|
|
|
|||
|
|
@ -69,14 +69,14 @@ def get_session():
|
|||
|
||||
"""Function for get the session from request object from bottle"""
|
||||
|
||||
return Session(request.environ.get('session', {}))
|
||||
return request.environ.get('session', Session())
|
||||
|
||||
def session_plugin(callback):
|
||||
|
||||
def wrapper(*args, **kwargs):
|
||||
|
||||
cookie=request.get_cookie(config.cookie_name)
|
||||
|
||||
|
||||
safe=None
|
||||
|
||||
if not cookie:
|
||||
|
|
@ -170,8 +170,8 @@ class SessionPlugin(object):
|
|||
except:
|
||||
session=Session()
|
||||
|
||||
#if 'session' in kwargs:
|
||||
kwargs['session']=session
|
||||
if 'session' in kwargs:
|
||||
kwargs['session']=session
|
||||
|
||||
#For compatibility with old sessions server-side style.
|
||||
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ def logout_admin(session={}):
|
|||
|
||||
redirect(app.get_url('admin_app.login_admin'))
|
||||
|
||||
@admin_app.get('/change_lang')
|
||||
@admin_app.get('/change_lang', name='admin_app.change_lang')
|
||||
def change_lang():
|
||||
|
||||
db=WebModel.connection()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ def check_login(callback):
|
|||
|
||||
return result
|
||||
else:
|
||||
abort(403)
|
||||
abort(403, 'You need a valid cookie for access')
|
||||
|
||||
if request.environ['session'].get('verify_auth', False):
|
||||
redirect(app.get_url('admin_app.need_auth'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue