Included support for apistar-mail

deb
androiddrew 7 years ago
parent 40951d8354
commit a52d431e0d

@ -6,6 +6,8 @@ from apistar.handlers import docs_urls, static_urls
from apistar.interfaces import Router, Injector, Auth from apistar.interfaces import Router, Injector, Auth
from apistar_jwt.authentication import JWTAuthentication from apistar_jwt.authentication import JWTAuthentication
from apistar_alembic_migrations import commands as migrate_commands from apistar_alembic_migrations import commands as migrate_commands
from apistar_mail import mail_component
import logbook import logbook
@ -81,7 +83,8 @@ _routes = _routes + auth_routes
_commands = sqlalchemy_backend.commands + commands + migrate_commands _commands = sqlalchemy_backend.commands + commands + migrate_commands
_components = sqlalchemy_backend.components + auth_components
_components = sqlalchemy_backend.components + auth_components + [mail_component]
def application_factory(settings={}, routes=_routes, commands=_commands, components=_components): def application_factory(settings={}, routes=_routes, commands=_commands, components=_components):

@ -4,8 +4,10 @@ from apistar import Component, Settings, http, Route, Include
from apistar.backends.sqlalchemy_backend import Session from apistar.backends.sqlalchemy_backend import Session
from apistar_jwt.authentication import get_jwt from apistar_jwt.authentication import get_jwt
from apistar_jwt.token import JWT from apistar_jwt.token import JWT
from apistar_mail import Message, Mail
from sqlalchemy.exc import IntegrityError, InvalidRequestError from sqlalchemy.exc import IntegrityError, InvalidRequestError
from cookie_api.models import User from cookie_api.models import User
auth_components = [ auth_components = [
@ -47,7 +49,7 @@ def logout():
# TODO Add user registration # 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') user_id = json_data.get('email')
password = json_data.get('password') password = json_data.get('password')
@ -65,7 +67,9 @@ def register(settings: Settings, json_data: http.RequestData, session: Session):
session.add(user) session.add(user)
session.commit() 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 = {} headers = {}
message = { message = {
'status': 'success', 'status': 'success',
@ -80,7 +84,7 @@ def user_profile():
# TODO Add email confirmation # TODO Add email confirmation
def confirm(settings: Settings, json_data: http.RequestData, session: Session): def confirm(json_data: http.RequestData, session: Session):
pass pass

@ -30,3 +30,37 @@ uritemplate==3.0.0
urllib3==1.22 urllib3==1.22
Werkzeug==0.12.2 Werkzeug==0.12.2
whitenoise==3.3.1 whitenoise==3.3.1
alembic==0.9.6
apistar==0.3.9
apistar-alembic-migrations==0.0.6
apistar-jwt==0.2.1
apistar-mail==0.2.0
bcrypt==3.1.4
certifi==2017.7.27.1
cffi==1.11.2
chardet==3.0.4
colorama==0.3.9
coreapi==2.3.3
coreschema==0.0.4
idna==2.6
itsdangerous==0.24
itypes==1.1.0
Jinja2==2.9.6
Logbook==1.1.0
Mako==1.0.7
MarkupSafe==1.0
marshmallow==2.15.0
psycopg2==2.7.3.1
py==1.4.34
pycparser==2.18
PyJWT==1.5.3
pytest==3.2.3
python-dateutil==2.6.1
python-editor==1.0.3
requests==2.18.4
six==1.11.0
SQLAlchemy==1.1.14
uritemplate==3.0.0
urllib3==1.22
Werkzeug==0.12.2
whitenoise==3.3.1

Loading…
Cancel
Save