Check validity on each modules

This commit is contained in:
Dita Aji Pratama 2024-06-19 06:53:25 +07:00
parent 14e42bc0d4
commit 56586d1d5d
5 changed files with 143 additions and 104 deletions

View File

@ -22,29 +22,28 @@ class home:
} }
def html(self, params): def html(self, params):
active_page = "Home" active_page = "Home"
allowed_roles = [0,1,2,3] allowed_roles = [0,1,2,3]
beaker_session = request.environ.get('beaker.session') beaker_session = request.environ.get('beaker.session')
jwt = beaker_session["token"] if "token" in beaker_session else None jwt = beaker_session["token"] if "token" in beaker_session else None
if jwt is not None: self.user = procedure_session.session().user(jwt, allowed_roles) if jwt is not None else self.user
self.user = procedure_session.session().user(jwt, allowed_roles)
user = self.user['data'] user = self.user['data']
if 'valid' in user and user['valid']['status'] == 0:
return Template(params["mako"]["website"]['index']).render( return redirect('/logout')
title = globalvar.title, else:
header = globalvar.header, return Template(params["mako"]["website"]['index']).render(
navbar = Template(params["mako"]["website"]['navbar']).render( title = globalvar.title,
menu = globalvar.menu['public']['navbar'], header = globalvar.header,
user_roles = user['profile']['roles'], navbar = Template(params["mako"]["website"]['navbar']).render(
active_page = active_page menu = globalvar.menu['public']['navbar'],
), user_roles = user['profile']['roles'],
footer = Template(params["mako"]["website"]['footer']).render( active_page = active_page
copyright = globalvar.copyright, ),
), footer = Template(params["mako"]["website"]['footer']).render(
container = Template(params["mako"]["website"]['container']).render( copyright = globalvar.copyright,
greeting = f"Welcome to your new web application! This placeholder page is here to let you know that your web framework is successfully set up and ready to go. Now, it's time to start building your project. Dive into the documentation to explore the features and capabilities at your disposal.", ),
user = user container = Template(params["mako"]["website"]['container']).render(
greeting = f"Welcome to your new web application! This placeholder page is here to let you know that your web framework is successfully set up and ready to go. Now, it's time to start building your project. Dive into the documentation to explore the features and capabilities at your disposal.",
user = user
)
) )
)

View File

@ -1,26 +1,30 @@
import mysql.connector as mariadb
from mako.template import Template from mako.template import Template
from config import globalvar, database from config import globalvar
from bottle import request
class login: class login:
def __init__(self): def __init__(self):
self.db_main = mariadb.connect(**database.db_main) pass
self.cursor = self.db_main.cursor(dictionary=True)
self.user_roles = [0] # Cari user roles disini
def html(self, params): def html(self, params):
active_page = "Login" active_page = "Login"
return Template(params["mako"]["website"]['index']).render( user_roles = [0]
title = globalvar.title, beaker_session = request.environ.get('beaker.session')
header = globalvar.header, jwt = beaker_session["token"] if "token" in beaker_session else None
navbar = Template(params["mako"]["website"]['navbar']).render( if jwt is not None:
menu = globalvar.menu['public']['navbar'], return redirect('/')
user_roles = self.user_roles, else:
active_page = active_page return Template(params["mako"]["website"]['index']).render(
), title = globalvar.title,
footer = Template(params["mako"]["website"]['footer']).render( header = globalvar.header,
copyright = globalvar.copyright, navbar = Template(params["mako"]["website"]['navbar']).render(
), menu = globalvar.menu['public']['navbar'],
container = Template(params["mako"]["website"]['container']).render() user_roles = user_roles,
) active_page = active_page
),
footer = Template(params["mako"]["website"]['footer']).render(
copyright = globalvar.copyright,
),
container = Template(params["mako"]["website"]['container']).render()
)

View File

@ -1,28 +1,45 @@
import mysql.connector as mariadb
from mako.template import Template from mako.template import Template
from config import globalvar, database from config import globalvar
from bottle import request
import procedure.session as procedure_session
class notme: class notme:
def __init__(self): def __init__(self):
self.db_main = mariadb.connect(**database.db_main) self.user = {
self.cursor = self.db_main.cursor(dictionary=True) "data":{
self.user_roles = [0] # Cari user roles disini "profile":{
"username":None,
"email":None,
"phone":None,
"roles":[0]
}
}
}
def html(self, params): def html(self, params):
active_page = None active_page = None
return Template(params["mako"]["website"]['index']).render( allowed_roles = [0,1,2,3]
title = globalvar.title, beaker_session = request.environ.get('beaker.session')
header = globalvar.header, jwt = beaker_session["token"] if "token" in beaker_session else None
navbar = Template(params["mako"]["website"]['navbar']).render( self.user = procedure_session.session().user(jwt, allowed_roles) if jwt is not None else self.user
menu = globalvar.menu['public']['navbar'], user = self.user['data']
user_roles = self.user_roles, if 'valid' in user and user['valid']['status'] == 0:
active_page = active_page return redirect('/logout')
), else:
footer = Template(params["mako"]["website"]['footer']).render( return Template(params["mako"]["website"]['index']).render(
copyright = globalvar.copyright, title = globalvar.title,
), header = globalvar.header,
container = Template(params["mako"]["website"]['container']).render( navbar = Template(params["mako"]["website"]['navbar']).render(
title = globalvar.title 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
)
) )
)

View File

@ -1,34 +1,36 @@
import mysql.connector as mariadb
from mako.template import Template from mako.template import Template
from config import globalvar, database from config import globalvar
from bottle import request
class register: class register:
def __init__(self): def __init__(self):
self.db_main = mariadb.connect(**database.db_main) pass
self.cursor = self.db_main.cursor(dictionary=True)
self.user_roles = [0] # Cari user roles disini
def html(self, params): def html(self, params):
roles = params["roles"]
roles = params["roles"] active_page = "Register"
active_page = "Register" user_roles = [0]
beaker_session = request.environ.get('beaker.session')
return Template(params["mako"]["website"]['index']).render( jwt = beaker_session["token"] if "token" in beaker_session else None
title = globalvar.title, if jwt is not None:
header = globalvar.header, return redirect('/')
navbar = Template(params["mako"]["website"]['navbar']).render( else:
menu = globalvar.menu['public']['navbar'], return Template(params["mako"]["website"]['index']).render(
user_roles = self.user_roles, title = globalvar.title,
active_page = active_page header = globalvar.header,
), navbar = Template(params["mako"]["website"]['navbar']).render(
footer = Template(params["mako"]["website"]['footer']).render( menu = globalvar.menu['public']['navbar'],
copyright = globalvar.copyright, user_roles = user_roles,
), active_page = active_page
container = Template(params["mako"]["website"]['container']).render( ),
title = globalvar.title, footer = Template(params["mako"]["website"]['footer']).render(
reCAPTCHA_client = globalvar.reCAPTCHA['client'], copyright = globalvar.copyright,
roles = roles, ),
production = globalvar.production container = Template(params["mako"]["website"]['container']).render(
title = globalvar.title,
reCAPTCHA_client = globalvar.reCAPTCHA['client'],
roles = roles,
production = globalvar.production
)
) )
)

View File

@ -1,26 +1,43 @@
import mysql.connector as mariadb
from mako.template import Template from mako.template import Template
from config import globalvar, database from config import globalvar
from bottle import request
import procedure.session as procedure_session
class verify: class verify:
def __init__(self): def __init__(self):
self.db_main = mariadb.connect(**database.db_main) self.user = {
self.cursor = self.db_main.cursor(dictionary=True) "data":{
self.user_roles = [0] # Cari user roles disini "profile":{
"username":None,
"email":None,
"phone":None,
"roles":[0]
}
}
}
def html(self, params): def html(self, params):
active_page = None active_page = None
return Template(params["mako"]["website"]['index']).render( allowed_roles = [0,1,2,3]
title = globalvar.title, beaker_session = request.environ.get('beaker.session')
header = globalvar.header, jwt = beaker_session["token"] if "token" in beaker_session else None
navbar = Template(params["mako"]["website"]['navbar']).render( self.user = procedure_session.session().user(jwt, allowed_roles) if jwt is not None else self.user
menu = globalvar.menu['public']['navbar'], user = self.user['data']
user_roles = self.user_roles, if 'valid' in user and user['valid']['status'] == 0:
active_page = active_page return redirect('/logout')
), else:
footer = Template(params["mako"]["website"]['footer']).render( return Template(params["mako"]["website"]['index']).render(
copyright = globalvar.copyright, title = globalvar.title,
), header = globalvar.header,
container = Template(params["mako"]["website"]['container']).render() 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()
)