Resend features

This commit is contained in:
Dita Aji Pratama 2024-06-17 21:47:59 +07:00
parent e8f0487e05
commit c8d9092ffc
2 changed files with 20 additions and 7 deletions

View File

@ -75,3 +75,18 @@ 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/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()

View File

@ -170,14 +170,12 @@ class auth:
token = result_unverified["token"].decode() token = result_unverified["token"].decode()
if result_unverified["count"] >= 1: if result_unverified["count"] >= 1:
loggorilla.prcss(APIADDR, "Generate URL") loggorilla.prcss(APIADDR, "Generate URL")
# TODO: set expired time
expired = datetime.datetime.now() + datetime.timedelta(minutes=30) # Can be hours or minutes expired = datetime.datetime.now() + datetime.timedelta(minutes=30) # Can be hours or minutes
expired_isoformat = expired.isoformat() expired_isoformat = expired.isoformat()
payload = { payload = {
"token" : token, "token" : token,
"expired": expired_isoformat "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']) token_encrypt = tokenguard.encode(payload, globalvar.ssh['key']['private'], globalvar.ssh['passphrase'])
verification_url = globalvar.verification_url(token_encrypt) verification_url = globalvar.verification_url(token_encrypt)
notme_url = globalvar.notme_url(token_encrypt) notme_url = globalvar.notme_url(token_encrypt)
@ -187,10 +185,10 @@ 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['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( 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(
header = self.smtpconfig['subject'],
verify = verification_url, verify = verification_url,
notme = notme_url notme = notme_url
) )