|
|
|
@ -4,8 +4,10 @@ from apistar import Component, Settings, http, Route, Include
|
|
|
|
|
from apistar.backends.sqlalchemy_backend import Session
|
|
|
|
|
from apistar_jwt.authentication import get_jwt
|
|
|
|
|
from apistar_jwt.token import JWT
|
|
|
|
|
from apistar_mail import Message, Mail
|
|
|
|
|
from sqlalchemy.exc import IntegrityError, InvalidRequestError
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from cookie_api.models import User
|
|
|
|
|
|
|
|
|
|
auth_components = [
|
|
|
|
@ -47,7 +49,7 @@ def logout():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO Add user registration
|
|
|
|
|
def register(settings: Settings, json_data: http.RequestData, session: Session):
|
|
|
|
|
def register(json_data: http.RequestData, session: Session, mail:Mail):
|
|
|
|
|
user_id = json_data.get('email')
|
|
|
|
|
password = json_data.get('password')
|
|
|
|
|
|
|
|
|
@ -65,7 +67,9 @@ def register(settings: Settings, json_data: http.RequestData, session: Session):
|
|
|
|
|
session.add(user)
|
|
|
|
|
session.commit()
|
|
|
|
|
|
|
|
|
|
# TODO Send off an email confirmation
|
|
|
|
|
msg = Message("Thank you for registering please confirm your email", recipients=[user_id])
|
|
|
|
|
mail.send(msg)
|
|
|
|
|
|
|
|
|
|
headers = {}
|
|
|
|
|
message = {
|
|
|
|
|
'status': 'success',
|
|
|
|
@ -80,7 +84,7 @@ def user_profile():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO Add email confirmation
|
|
|
|
|
def confirm(settings: Settings, json_data: http.RequestData, session: Session):
|
|
|
|
|
def confirm(json_data: http.RequestData, session: Session):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|