From c8d9092ffc1fb5ce81c00fa4db1526914b4dfe95 Mon Sep 17 00:00:00 2001 From: ditaajipratama Date: Mon, 17 Jun 2024 21:47:59 +0700 Subject: [PATCH] Resend features --- app/handler.py | 15 +++++++++++++++ app/modules/api/auth.py | 12 +++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/handler.py b/app/handler.py index 094627b..6655471 100644 --- a/app/handler.py +++ b/app/handler.py @@ -75,3 +75,18 @@ def index(): except Exception as e: print(str(e)) return json.dumps({}, indent = 2).encode() + +@app.route('/api/auth/registration/resend', method='GET') +def index(): + try: + params = { + "email" : request.query.email, + "mako" : { + "email" : template_email.main(directory.page["email"], "verification") + } + } + response.content_type = 'application/json' + return json.dumps(api_auth.auth().resend(params), indent = 2).encode() + except Exception as e: + print(str(e)) + return json.dumps({}, indent = 2).encode() diff --git a/app/modules/api/auth.py b/app/modules/api/auth.py index 6e84805..469735f 100644 --- a/app/modules/api/auth.py +++ b/app/modules/api/auth.py @@ -170,14 +170,12 @@ class auth: token = result_unverified["token"].decode() if result_unverified["count"] >= 1: loggorilla.prcss(APIADDR, "Generate URL") - # TODO: set expired time expired = datetime.datetime.now() + datetime.timedelta(minutes=30) # Can be hours or minutes expired_isoformat = expired.isoformat() payload = { "token" : token, "expired": expired_isoformat } - # TODO: Config SSH key for tokenguard and set verification URL token_encrypt = tokenguard.encode(payload, globalvar.ssh['key']['private'], globalvar.ssh['passphrase']) verification_url = globalvar.verification_url(token_encrypt) notme_url = globalvar.notme_url(token_encrypt) @@ -187,12 +185,12 @@ class auth: self.smtpconfig['text' ] = f"Please visit this link to complete the registration: {verification_url}. You are not registering this? report on this: {notme_url}." self.smtpconfig['html' ] = Template(params["mako"]["email"]['index']).render( title = globalvar.title, - heading = self.smtpconfig['subject'], - image = "https://colorlib.com/etc/email-template/10/images/email.png", - unsubscribe = "#", + header = globalvar.title, + copyright = globalvar.copyright, container = Template(params["mako"]["email"]['container']).render( - verify = verification_url, - notme = notme_url + header = self.smtpconfig['subject'], + verify = verification_url, + notme = notme_url ) ) sendwave.smtp(self.smtpconfig)