authsquare/app/modules/public/verify.py

44 lines
1.6 KiB
Python

from mako.template import Template
from config import globalvar
from bottle import request
import procedure.session as procedure_session
class verify:
def __init__(self):
self.user = {
"data":{
"profile":{
"username":None,
"email":None,
"phone":None,
"roles":[0]
}
}
}
def html(self, params):
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()
)