def register(cls, data): hashed_pw = security.hash_password({"password" : data['password']}) data["password"] = hashed_pw result = user_svc.create_user(data) s_info = user_svc.get_by_email(data['email']) tok = security.generate_token(s_info) return result, tok
def login(cls, login_info): test = security.hash_password({"password" : login_info['password']}) s_info = user_svc.get_by_email(login_info['email']) if test == s_info['password'].encode(): tok = security.generate_token(s_info) return tok else: return False
def t2(): user = { "last_name": "Gamgee", "first_name": "Sam", "email": "*****@*****.**", "password": "******" } r = UserService.create_user(user) print("Result = ", r)
def t1(): r = UserService.get_by_email('*****@*****.**') print("Result = \n", json.dumps(r, indent=2))
def test_delete(): user_info = {"email": "*****@*****.**"} r = UserService.delete_user(user_info)