-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsignup.py
More file actions
22 lines (17 loc) · 830 Bytes
/
signup.py
File metadata and controls
22 lines (17 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from collections import namedtuple
import configuration
import inmemorydb as db
returnData = namedtuple('returnData', 'message, backToUrl, caption')
def signup(request) -> returnData:
"""
:rtype: returnData
"""
user_name = request.form['userName']
user_password = request.form['password']
if db.is_user_exist(user_name):
msg_str: str = "OhOo sorry, {}, is already taken, Please try something else".format(user_name)
return returnData(message=msg_str, backToUrl=configuration.get_config("signupAddress"), caption="Sign up")
else:
db.set_user(user_name, user_password)
msg_str: str = "Thanks {}, for the registration, You can login now".format(user_name)
return returnData(message=msg_str, backToUrl=configuration.get_config("loginAddress"), caption="Login")