mirror of
https://github.com/supleed2/ELEC60013-ES-CW1.git
synced 2024-12-22 21:45:48 +00:00
Move Server to subdir
This commit is contained in:
parent
e507bb60b5
commit
cd472b6a8b
0
.gitignore → Server/.gitignore
vendored
0
.gitignore → Server/.gitignore
vendored
26
lib/utils.py
26
lib/utils.py
|
@ -1,26 +0,0 @@
|
||||||
from random import randint
|
|
||||||
from flask import current_app
|
|
||||||
from flask_mail import Mail, Message
|
|
||||||
from firebase_admin import firestore
|
|
||||||
|
|
||||||
def sendMail(subject, sender, recipients, body):
|
|
||||||
mail = Mail(current_app)
|
|
||||||
msg = Message(subject, sender=sender, recipients=recipients)
|
|
||||||
msg.body = body
|
|
||||||
mail.send(msg)
|
|
||||||
|
|
||||||
def saveVerificationCode(uid):
|
|
||||||
code = randint(100000, 999999)
|
|
||||||
data = {
|
|
||||||
u'code': code
|
|
||||||
}
|
|
||||||
firestore.client().collection(u'verification').document(uid).set(data)
|
|
||||||
return code
|
|
||||||
|
|
||||||
def sendVerificationMail(name, email, code):
|
|
||||||
subject = 'Please verify your email for BarkFinder'
|
|
||||||
sender = 'legbarkr@gmail.com'
|
|
||||||
recipients = [email]
|
|
||||||
body = '''Hey {}! Thank you for signing up for BarkFinder.
|
|
||||||
In order to use our sevices, could you please verify your email address by logging in and entering this code {}'''.format(name, code)
|
|
||||||
sendMail(subject, sender, recipients, body)
|
|
Loading…
Reference in a new issue