-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoolz.py
More file actions
47 lines (37 loc) · 1.2 KB
/
Copy pathtoolz.py
File metadata and controls
47 lines (37 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import random
import re
import os
import string
from flask_mail import Message
from app import mail
from config import Config
import smtplib
def validate_email(email):
if email is None:
return False
pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$'
if re.match(pattern, email):
return True
else:
return False
# generate a random number for the token
def random_generator(size=6, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size))
# validate_phone
def validate_phone_update(existing_phone, new_phone):
if new_phone == "":
new_phone = phone
# new phone is not provided
if new_phone is None:
return True
# must add new phone number
if new_phone is not None and existing_phone is not None:
print("ERROR : Cannot input a new phone number because one already exists")
return False
return False
# Email Sender function
def send_email(subject, receiver, text_body, html_body):
msg = Message(subject=subject, sender=('FinTech', Config.MAIL_USERNAME), recipients=[receiver])
msg.body = text_body
msg.html = html_body
mail.send(msg)