authsquare/app/modules/public/notme.py

46 lines
1.7 KiB
Python
Raw Normal View History

2024-06-17 21:33:07 +07:00
from mako.template import Template
2024-06-19 06:53:25 +07:00
from config import globalvar
from bottle import request
import procedure.session as procedure_session
2024-06-17 21:33:07 +07:00
class notme:
def __init__(self):
2024-06-19 06:53:25 +07:00
self.user = {
"data":{
"profile":{
"username":None,
"email":None,
"phone":None,
"roles":[0]
}
}
}
2024-06-17 21:33:07 +07:00
def html(self, params):
2024-06-19 06:53:25 +07:00
active_page = None
allowed_roles = [0,1,2,3]
beaker_session = request.environ.get('beaker.session')
jwt = beaker_session["token"] if "token" in beaker_session else None
self.user = procedure_session.session().user(jwt, allowed_roles) if jwt is not None else self.user
user = self.user['data']
if 'valid' in user and user['valid']['status'] == 0:
return redirect('/logout')
else:
return Template(params["mako"]["website"]['index']).render(
title = globalvar.title,
header = globalvar.header,
navbar = Template(params["mako"]["website"]['navbar']).render(
menu = globalvar.menu['public']['navbar'],
user_roles = user['profile']['roles'],
active_page = active_page
),
footer = Template(params["mako"]["website"]['footer']).render(
copyright = globalvar.copyright,
),
container = Template(params["mako"]["website"]['container']).render(
title = globalvar.title
)
2024-06-17 21:33:07 +07:00
)