Verify features

This commit is contained in:
Dita Aji Pratama 2024-06-18 23:36:54 +07:00
parent c8d9092ffc
commit 82f0e84428
4 changed files with 61 additions and 5 deletions

View File

@ -16,6 +16,7 @@ import templates.postcard.main as template_email
import modules.public.home as public_home import modules.public.home as public_home
import modules.public.register as public_register import modules.public.register as public_register
import modules.public.notme as public_notme import modules.public.notme as public_notme
import modules.public.verify as public_verify
import modules.api.auth as api_auth import modules.api.auth as api_auth
@ -49,6 +50,15 @@ def index():
} }
return public_notme.notme().html(params) return public_notme.notme().html(params)
@app.route('/verify', method='GET')
def index():
params = {
"mako" : {
"website" : template_public.main(directory.page["public"], "verify")
}
}
return public_verify.verify().html(params)
@app.route('/api/auth/registration/register/<roles>', method='POST') @app.route('/api/auth/registration/register/<roles>', method='POST')
def index(roles): def index(roles):
try: try:
@ -90,3 +100,16 @@ def index():
except Exception as e: except Exception as e:
print(str(e)) print(str(e))
return json.dumps({}, indent = 2).encode() return json.dumps({}, indent = 2).encode()
@app.route('/api/auth/registration/verify', method='POST')
def index():
try:
params = request.json
params["mako" ] = {
"email" : template_email.main(directory.page["email"], "message")
}
response.content_type = 'application/json'
return json.dumps(api_auth.auth().verify(params), indent = 2).encode()
except Exception as e:
print(str(e))
return json.dumps({}, indent = 2).encode()

View File

@ -306,7 +306,6 @@ class auth:
self.cursor.execute("BEGIN;") self.cursor.execute("BEGIN;")
try: try:
loggorilla.prcss(APIADDR, "Decrypt token") loggorilla.prcss(APIADDR, "Decrypt token")
# TODO: Config SSH key for tokenguard
payload = tokenguard.decode(token_encrypt, globalvar.ssh['key']['public']) payload = tokenguard.decode(token_encrypt, globalvar.ssh['key']['public'])
token = payload['token'] token = payload['token']
expired = datetime.datetime.fromisoformat(payload['expired']) expired = datetime.datetime.fromisoformat(payload['expired'])
@ -339,11 +338,10 @@ class auth:
self.smtpconfig['to' ] = result_profile['email'] self.smtpconfig['to' ] = result_profile['email']
self.smtpconfig['text' ] = f"Welcome. Now your account is verified." self.smtpconfig['text' ] = f"Welcome. Now your account is verified."
loggorilla.fyinf(APIADDR, "2") loggorilla.fyinf(APIADDR, "2")
self.smtpconfig['html' ] = Template(params["mako"]["email"]['template']).render( self.smtpconfig['html' ] = Template(params["mako"]["email"]['index']).render(
title = globalvar.title, title = globalvar.title,
heading = self.smtpconfig['subject'], header = globalvar.title,
image = "https://colorlib.com/etc/email-template/10/images/email.png", copyright = globalvar.copyright,
unsubscribe = "#",
container = Template(params["mako"]["email"]['container']).render( container = Template(params["mako"]["email"]['container']).render(
message = "Welcome. Now your account is verified." message = "Welcome. Now your account is verified."
) )

View File

@ -0,0 +1,26 @@
import mysql.connector as mariadb
from mako.template import Template
from config import globalvar, database
class verify:
def __init__(self):
self.db_main = mariadb.connect(**database.db_main)
self.cursor = self.db_main.cursor(dictionary=True)
self.user_roles = [0] # Cari user roles disini
def html(self, params):
active_page = None
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 = self.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

@ -0,0 +1,9 @@
<h1>Verify</h1>
<script type="text/javascript" src="/js/carrack.js"></script>
<div id="alert-response" role="alert">
<b id="alert-status">Loading...</b> <span id="alert-desc">Please wait...</span>
</div>
<script type="text/javascript" src="/js/auth/verify.js"></script>