Implementing account validation on all public pages
This commit is contained in:
parent
c0efe31a0f
commit
a440a32ad6
@ -1,6 +1,9 @@
|
|||||||
from mako.template import Template
|
from mako.template import Template
|
||||||
from config import globalvar
|
from config import globalvar
|
||||||
from bottle import request
|
from bottle import redirect, abort
|
||||||
|
from scripts import loggorilla
|
||||||
|
|
||||||
|
import procedure.validation as procedure_validation
|
||||||
|
|
||||||
class forgot:
|
class forgot:
|
||||||
|
|
||||||
@ -8,23 +11,26 @@ class forgot:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def html(self, params):
|
def html(self, params):
|
||||||
|
APIADDR = "/forgot"
|
||||||
|
|
||||||
|
loggorilla.prcss(APIADDR, "Define page parameters")
|
||||||
active_page = "Forgot"
|
active_page = "Forgot"
|
||||||
user_roles = [0]
|
allowed_roles = [0]
|
||||||
beaker_session = request.environ.get('beaker.session')
|
|
||||||
jwt = beaker_session["token"] if "token" in beaker_session else None
|
loggorilla.prcss(APIADDR, "Account validation")
|
||||||
if jwt is not None:
|
user_validation = procedure_validation.validation().account(APIADDR, allowed_roles)
|
||||||
return redirect('/')
|
user = user_validation['data']
|
||||||
else:
|
|
||||||
return Template(params["mako"]["website"]['index']).render(
|
return Template(params["mako"]["website"]['index']).render(
|
||||||
title = globalvar.title,
|
title = globalvar.title,
|
||||||
header = globalvar.header,
|
header = globalvar.header,
|
||||||
navbar = Template(params["mako"]["website"]['navbar']).render(
|
navbar = Template(params["mako"]["website"]['navbar']).render(
|
||||||
menu = globalvar.menu['public']['navbar'],
|
menu = globalvar.menu['public']['navbar'],
|
||||||
user_roles = user_roles,
|
user_roles = user['profile']['roles'],
|
||||||
active_page = active_page
|
active_page = active_page
|
||||||
),
|
),
|
||||||
footer = Template(params["mako"]["website"]['footer']).render(
|
footer = Template(params["mako"]["website"]['footer']).render(
|
||||||
copyright = globalvar.copyright,
|
copyright = globalvar.copyright,
|
||||||
),
|
),
|
||||||
container = Template(params["mako"]["website"]['container']).render()
|
container = Template(params["mako"]["website"]['container']).render()
|
||||||
)
|
)
|
||||||
|
@ -1,49 +1,39 @@
|
|||||||
import mysql.connector as mariadb
|
from mako.template import Template
|
||||||
from mako.template import Template
|
from config import globalvar
|
||||||
from config import globalvar, database
|
from bottle import redirect, abort
|
||||||
from bottle import request
|
from scripts import loggorilla
|
||||||
|
|
||||||
import procedure.session as procedure_session
|
import procedure.validation as procedure_validation
|
||||||
|
|
||||||
class home:
|
class home:
|
||||||
|
|
||||||
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 = {
|
|
||||||
"data":{
|
|
||||||
"profile":{
|
|
||||||
"username":None,
|
|
||||||
"email":None,
|
|
||||||
"phone":None,
|
|
||||||
"roles":[0]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def html(self, params):
|
def html(self, params):
|
||||||
|
APIADDR = "/"
|
||||||
|
|
||||||
|
loggorilla.prcss(APIADDR, "Define page parameters")
|
||||||
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')
|
|
||||||
jwt = beaker_session["token"] if "token" in beaker_session else None
|
loggorilla.prcss(APIADDR, "Account validation")
|
||||||
self.user = procedure_session.session().user(jwt, allowed_roles) if jwt is not None else self.user
|
user_validation = procedure_validation.validation().account(APIADDR, allowed_roles)
|
||||||
user = self.user['data']
|
user = user_validation['data']
|
||||||
if 'valid' in user and user['valid']['status'] == 0:
|
|
||||||
return redirect('/logout')
|
return Template(params["mako"]["website"]['index']).render(
|
||||||
else:
|
title = globalvar.title,
|
||||||
return Template(params["mako"]["website"]['index']).render(
|
header = globalvar.header,
|
||||||
title = globalvar.title,
|
navbar = Template(params["mako"]["website"]['navbar']).render(
|
||||||
header = globalvar.header,
|
menu = globalvar.menu['public']['navbar'],
|
||||||
navbar = Template(params["mako"]["website"]['navbar']).render(
|
user_roles = user['profile']['roles'],
|
||||||
menu = globalvar.menu['public']['navbar'],
|
active_page = active_page
|
||||||
user_roles = user['profile']['roles'],
|
),
|
||||||
active_page = active_page
|
footer = Template(params["mako"]["website"]['footer']).render(
|
||||||
),
|
copyright = globalvar.copyright,
|
||||||
footer = Template(params["mako"]["website"]['footer']).render(
|
),
|
||||||
copyright = globalvar.copyright,
|
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.",
|
||||||
container = Template(params["mako"]["website"]['container']).render(
|
user = user
|
||||||
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
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
from mako.template import Template
|
from mako.template import Template
|
||||||
from config import globalvar
|
from config import globalvar
|
||||||
from bottle import request
|
from bottle import redirect, abort
|
||||||
|
from scripts import loggorilla
|
||||||
|
|
||||||
|
import procedure.validation as procedure_validation
|
||||||
|
|
||||||
class login:
|
class login:
|
||||||
|
|
||||||
@ -8,23 +11,26 @@ class login:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def html(self, params):
|
def html(self, params):
|
||||||
|
APIADDR = "/login"
|
||||||
|
|
||||||
|
loggorilla.prcss(APIADDR, "Define page parameters")
|
||||||
active_page = "Login"
|
active_page = "Login"
|
||||||
user_roles = [0]
|
allowed_roles = [0]
|
||||||
beaker_session = request.environ.get('beaker.session')
|
|
||||||
jwt = beaker_session["token"] if "token" in beaker_session else None
|
loggorilla.prcss(APIADDR, "Account validation")
|
||||||
if jwt is not None:
|
user_validation = procedure_validation.validation().account(APIADDR, allowed_roles)
|
||||||
return redirect('/')
|
user = user_validation['data']
|
||||||
else:
|
|
||||||
return Template(params["mako"]["website"]['index']).render(
|
return Template(params["mako"]["website"]['index']).render(
|
||||||
title = globalvar.title,
|
title = globalvar.title,
|
||||||
header = globalvar.header,
|
header = globalvar.header,
|
||||||
navbar = Template(params["mako"]["website"]['navbar']).render(
|
navbar = Template(params["mako"]["website"]['navbar']).render(
|
||||||
menu = globalvar.menu['public']['navbar'],
|
menu = globalvar.menu['public']['navbar'],
|
||||||
user_roles = user_roles,
|
user_roles = user['profile']['roles'],
|
||||||
active_page = active_page
|
active_page = active_page
|
||||||
),
|
),
|
||||||
footer = Template(params["mako"]["website"]['footer']).render(
|
footer = Template(params["mako"]["website"]['footer']).render(
|
||||||
copyright = globalvar.copyright,
|
copyright = globalvar.copyright,
|
||||||
),
|
),
|
||||||
container = Template(params["mako"]["website"]['container']).render()
|
container = Template(params["mako"]["website"]['container']).render()
|
||||||
)
|
)
|
||||||
|
@ -1,45 +1,38 @@
|
|||||||
from mako.template import Template
|
from mako.template import Template
|
||||||
from config import globalvar
|
from config import globalvar
|
||||||
from bottle import request
|
from bottle import redirect, abort
|
||||||
|
from scripts import loggorilla
|
||||||
|
|
||||||
import procedure.session as procedure_session
|
import procedure.validation as procedure_validation
|
||||||
|
|
||||||
class notme:
|
class notme:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.user = {
|
pass
|
||||||
"data":{
|
|
||||||
"profile":{
|
|
||||||
"username":None,
|
|
||||||
"email":None,
|
|
||||||
"phone":None,
|
|
||||||
"roles":[0]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def html(self, params):
|
def html(self, params):
|
||||||
active_page = None
|
APIADDR = "/notme"
|
||||||
|
|
||||||
|
loggorilla.prcss(APIADDR, "Define page parameters")
|
||||||
|
active_page = "Not Me"
|
||||||
allowed_roles = [0,1,2,3]
|
allowed_roles = [0,1,2,3]
|
||||||
beaker_session = request.environ.get('beaker.session')
|
|
||||||
jwt = beaker_session["token"] if "token" in beaker_session else None
|
loggorilla.prcss(APIADDR, "Account validation")
|
||||||
self.user = procedure_session.session().user(jwt, allowed_roles) if jwt is not None else self.user
|
user_validation = procedure_validation.validation().account(APIADDR, allowed_roles)
|
||||||
user = self.user['data']
|
user = user_validation['data']
|
||||||
if 'valid' in user and user['valid']['status'] == 0:
|
|
||||||
return redirect('/logout')
|
return Template(params["mako"]["website"]['index']).render(
|
||||||
else:
|
title = globalvar.title,
|
||||||
return Template(params["mako"]["website"]['index']).render(
|
header = globalvar.header,
|
||||||
title = globalvar.title,
|
navbar = Template(params["mako"]["website"]['navbar']).render(
|
||||||
header = globalvar.header,
|
menu = globalvar.menu['public']['navbar'],
|
||||||
navbar = Template(params["mako"]["website"]['navbar']).render(
|
user_roles = user['profile']['roles'],
|
||||||
menu = globalvar.menu['public']['navbar'],
|
active_page = active_page
|
||||||
user_roles = user['profile']['roles'],
|
),
|
||||||
active_page = active_page
|
footer = Template(params["mako"]["website"]['footer']).render(
|
||||||
),
|
copyright = globalvar.copyright,
|
||||||
footer = Template(params["mako"]["website"]['footer']).render(
|
),
|
||||||
copyright = globalvar.copyright,
|
container = Template(params["mako"]["website"]['container']).render(
|
||||||
),
|
title = globalvar.title
|
||||||
container = Template(params["mako"]["website"]['container']).render(
|
|
||||||
title = globalvar.title
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
from mako.template import Template
|
from mako.template import Template
|
||||||
from config import globalvar
|
from config import globalvar
|
||||||
from bottle import request
|
from bottle import redirect, abort
|
||||||
|
from scripts import loggorilla
|
||||||
|
|
||||||
|
import procedure.validation as procedure_validation
|
||||||
|
|
||||||
class register:
|
class register:
|
||||||
|
|
||||||
@ -8,29 +11,32 @@ class register:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def html(self, params):
|
def html(self, params):
|
||||||
roles = params["roles"]
|
APIADDR = "/register"
|
||||||
|
|
||||||
|
loggorilla.prcss(APIADDR, "Define page parameters")
|
||||||
active_page = "Register"
|
active_page = "Register"
|
||||||
user_roles = [0]
|
allowed_roles = [0]
|
||||||
beaker_session = request.environ.get('beaker.session')
|
roles = params["roles"]
|
||||||
jwt = beaker_session["token"] if "token" in beaker_session else None
|
|
||||||
if jwt is not None:
|
loggorilla.prcss(APIADDR, "Account validation")
|
||||||
return redirect('/')
|
user_validation = procedure_validation.validation().account(APIADDR, allowed_roles)
|
||||||
else:
|
user = user_validation['data']
|
||||||
return Template(params["mako"]["website"]['index']).render(
|
|
||||||
title = globalvar.title,
|
return Template(params["mako"]["website"]['index']).render(
|
||||||
header = globalvar.header,
|
title = globalvar.title,
|
||||||
navbar = Template(params["mako"]["website"]['navbar']).render(
|
header = globalvar.header,
|
||||||
menu = globalvar.menu['public']['navbar'],
|
navbar = Template(params["mako"]["website"]['navbar']).render(
|
||||||
user_roles = user_roles,
|
menu = globalvar.menu['public']['navbar'],
|
||||||
active_page = active_page
|
user_roles = user['profile']['roles'],
|
||||||
),
|
active_page = active_page
|
||||||
footer = Template(params["mako"]["website"]['footer']).render(
|
),
|
||||||
copyright = globalvar.copyright,
|
footer = Template(params["mako"]["website"]['footer']).render(
|
||||||
),
|
copyright = globalvar.copyright,
|
||||||
container = Template(params["mako"]["website"]['container']).render(
|
),
|
||||||
title = globalvar.title,
|
container = Template(params["mako"]["website"]['container']).render(
|
||||||
reCAPTCHA_client = globalvar.reCAPTCHA['client'],
|
title = globalvar.title,
|
||||||
roles = roles,
|
reCAPTCHA_client = globalvar.reCAPTCHA['client'],
|
||||||
production = globalvar.production
|
roles = roles,
|
||||||
)
|
production = globalvar.production
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
from mako.template import Template
|
from mako.template import Template
|
||||||
from config import globalvar
|
from config import globalvar
|
||||||
from bottle import request
|
from bottle import redirect, abort
|
||||||
|
from scripts import loggorilla
|
||||||
|
|
||||||
|
import procedure.validation as procedure_validation
|
||||||
|
|
||||||
class reset:
|
class reset:
|
||||||
|
|
||||||
@ -8,23 +11,26 @@ class reset:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def html(self, params):
|
def html(self, params):
|
||||||
|
APIADDR = "/reset"
|
||||||
|
|
||||||
|
loggorilla.prcss(APIADDR, "Define page parameters")
|
||||||
active_page = "Reset"
|
active_page = "Reset"
|
||||||
user_roles = [0]
|
allowed_roles = [0]
|
||||||
beaker_session = request.environ.get('beaker.session')
|
|
||||||
jwt = beaker_session["token"] if "token" in beaker_session else None
|
loggorilla.prcss(APIADDR, "Account validation")
|
||||||
if jwt is not None:
|
user_validation = procedure_validation.validation().account(APIADDR, allowed_roles)
|
||||||
return redirect('/')
|
user = user_validation['data']
|
||||||
else:
|
|
||||||
return Template(params["mako"]["website"]['index']).render(
|
return Template(params["mako"]["website"]['index']).render(
|
||||||
title = globalvar.title,
|
title = globalvar.title,
|
||||||
header = globalvar.header,
|
header = globalvar.header,
|
||||||
navbar = Template(params["mako"]["website"]['navbar']).render(
|
navbar = Template(params["mako"]["website"]['navbar']).render(
|
||||||
menu = globalvar.menu['public']['navbar'],
|
menu = globalvar.menu['public']['navbar'],
|
||||||
user_roles = user_roles,
|
user_roles = user['profile']['roles'],
|
||||||
active_page = active_page
|
active_page = active_page
|
||||||
),
|
),
|
||||||
footer = Template(params["mako"]["website"]['footer']).render(
|
footer = Template(params["mako"]["website"]['footer']).render(
|
||||||
copyright = globalvar.copyright,
|
copyright = globalvar.copyright,
|
||||||
),
|
),
|
||||||
container = Template(params["mako"]["website"]['container']).render()
|
container = Template(params["mako"]["website"]['container']).render()
|
||||||
)
|
)
|
||||||
|
@ -1,43 +1,36 @@
|
|||||||
from mako.template import Template
|
from mako.template import Template
|
||||||
from config import globalvar
|
from config import globalvar
|
||||||
from bottle import request
|
from bottle import redirect, abort
|
||||||
|
from scripts import loggorilla
|
||||||
|
|
||||||
import procedure.session as procedure_session
|
import procedure.validation as procedure_validation
|
||||||
|
|
||||||
class verify:
|
class verify:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.user = {
|
pass
|
||||||
"data":{
|
|
||||||
"profile":{
|
|
||||||
"username":None,
|
|
||||||
"email":None,
|
|
||||||
"phone":None,
|
|
||||||
"roles":[0]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def html(self, params):
|
def html(self, params):
|
||||||
active_page = None
|
APIADDR = "/verify"
|
||||||
allowed_roles = [0,1,2,3]
|
|
||||||
beaker_session = request.environ.get('beaker.session')
|
loggorilla.prcss(APIADDR, "Define page parameters")
|
||||||
jwt = beaker_session["token"] if "token" in beaker_session else None
|
active_page = "Verify"
|
||||||
self.user = procedure_session.session().user(jwt, allowed_roles) if jwt is not None else self.user
|
allowed_roles = [0]
|
||||||
user = self.user['data']
|
|
||||||
if 'valid' in user and user['valid']['status'] == 0:
|
loggorilla.prcss(APIADDR, "Account validation")
|
||||||
return redirect('/logout')
|
user_validation = procedure_validation.validation().account(APIADDR, allowed_roles)
|
||||||
else:
|
user = user_validation['data']
|
||||||
return Template(params["mako"]["website"]['index']).render(
|
|
||||||
title = globalvar.title,
|
return Template(params["mako"]["website"]['index']).render(
|
||||||
header = globalvar.header,
|
title = globalvar.title,
|
||||||
navbar = Template(params["mako"]["website"]['navbar']).render(
|
header = globalvar.header,
|
||||||
menu = globalvar.menu['public']['navbar'],
|
navbar = Template(params["mako"]["website"]['navbar']).render(
|
||||||
user_roles = user['profile']['roles'],
|
menu = globalvar.menu['public']['navbar'],
|
||||||
active_page = active_page
|
user_roles = user['profile']['roles'],
|
||||||
),
|
active_page = active_page
|
||||||
footer = Template(params["mako"]["website"]['footer']).render(
|
),
|
||||||
copyright = globalvar.copyright,
|
footer = Template(params["mako"]["website"]['footer']).render(
|
||||||
),
|
copyright = globalvar.copyright,
|
||||||
container = Template(params["mako"]["website"]['container']).render()
|
),
|
||||||
)
|
container = Template(params["mako"]["website"]['container']).render()
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user