Compare commits
2 Commits
3e85e6375f
...
b9d0f28a76
Author | SHA1 | Date | |
---|---|---|---|
b9d0f28a76 | |||
a6449c6962 |
@ -236,6 +236,37 @@ class auth:
|
||||
self.db_main.close()
|
||||
return response
|
||||
|
||||
def invite(self, params):
|
||||
APIADDR = "/api/auth/invite"
|
||||
response = {}
|
||||
allowed_roles = [1,2]
|
||||
allowed_invitation = globalvar.allowed_invitation
|
||||
self.cursor.execute("BEGIN;")
|
||||
try:
|
||||
loggorilla.prcss(APIADDR, "Define parameters")
|
||||
roles = params["roles" ]
|
||||
email = params["email" ]
|
||||
username = params["username" ]
|
||||
password = params["password" ] # Admin should insert their password for send invitation confirmation
|
||||
loggorilla.prcss(APIADDR, "Extract the Authorization token from Header")
|
||||
auth_header = request.get_header('Authorization')
|
||||
jwt = auth_header.split(' ')[1]
|
||||
payload = tokenguard.decode(jwt, globalvar.ssh['key']['public'])
|
||||
session_id = payload["session"]["id"]
|
||||
loggorilla.prcss(APIADDR, "Account validation")
|
||||
user_validation = procedure_validation.validation().account(APIADDR, allowed_roles, token)
|
||||
user = user_validation['data']
|
||||
except Exception as e:
|
||||
self.cursor.execute("ROLLBACK;")
|
||||
loggorilla.error(APIADDR, str(e) )
|
||||
response["status" ] = "failed"
|
||||
response["desc" ] = "Internal Server Error. Please contact us if you still have an error."
|
||||
finally:
|
||||
self.cursor.execute("COMMIT;")
|
||||
self.cursor.close()
|
||||
self.db_main.close()
|
||||
return response
|
||||
|
||||
def login(self, params):
|
||||
APIADDR = "/api/auth/login"
|
||||
response = {}
|
||||
|
6
pages/email/accept.html
Normal file
6
pages/email/accept.html
Normal file
@ -0,0 +1,6 @@
|
||||
<h2>Accept Invitation</h2>
|
||||
|
||||
<p>Please visit this link below to accept the invitation.</p>
|
||||
<a href="${accept}" class="button">
|
||||
Accept
|
||||
</a>
|
@ -77,3 +77,18 @@ class webmail():
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
def invitation(self, APIADDR, params, data):
|
||||
return {
|
||||
"subject" : f"{globalvar.title} invitation",
|
||||
"text" : f"Please visit this link to accept the invitation: {data['accept']}",
|
||||
"html" : Template(params["mako"]["email"]['index']).render(
|
||||
title = globalvar.title,
|
||||
header = globalvar.title,
|
||||
copyright = globalvar.copyright,
|
||||
container = Template(params["mako"]["email"]['container']).render(
|
||||
header = "One more step to complete your invitation!",
|
||||
accept = data['accept' ]
|
||||
)
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user