PR comments
This commit is contained in:
parent
39b035a123
commit
bfb1ae6371
|
@ -25,6 +25,7 @@ from app.errors import (
|
||||||
)
|
)
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
from app.models import Alias, Contact, EmailLog, User
|
from app.models import Alias, Contact, EmailLog, User
|
||||||
|
from app.utils import sanitize_email
|
||||||
|
|
||||||
|
|
||||||
def email_validator():
|
def email_validator():
|
||||||
|
@ -65,6 +66,7 @@ def create_contact(user: User, alias: Alias, contact_address: str) -> Contact:
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise ErrAddressInvalid(contact_address)
|
raise ErrAddressInvalid(contact_address)
|
||||||
|
|
||||||
|
contact_email = sanitize_email(contact_email)
|
||||||
if not is_valid_email(contact_email):
|
if not is_valid_email(contact_email):
|
||||||
raise ErrAddressInvalid(contact_email)
|
raise ErrAddressInvalid(contact_email)
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ class ErrContactAlreadyExists(SLException):
|
||||||
"""raised when a contact already exists"""
|
"""raised when a contact already exists"""
|
||||||
|
|
||||||
# TODO: type-hint this as a contact when models are almost dataclasses and don't import errors
|
# TODO: type-hint this as a contact when models are almost dataclasses and don't import errors
|
||||||
def __init__(self, contact):
|
def __init__(self, contact: "Contact"): # noqa: F821
|
||||||
self.contact = contact
|
self.contact = contact
|
||||||
|
|
||||||
def error_for_user(self) -> str:
|
def error_for_user(self) -> str:
|
||||||
|
|
|
@ -4,12 +4,6 @@
|
||||||
|
|
||||||
container_name=sl-db-new-migration
|
container_name=sl-db-new-migration
|
||||||
|
|
||||||
if [ "$#" -lt "1" ]; then
|
|
||||||
echo "What is this migration for?"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
reason="$@"
|
|
||||||
|
|
||||||
# create a postgres database for SimpleLogin
|
# create a postgres database for SimpleLogin
|
||||||
docker rm -f ${container_name}
|
docker rm -f ${container_name}
|
||||||
docker run -p 25432:5432 --name ${container_name} -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=sl -d postgres:13
|
docker run -p 25432:5432 --name ${container_name} -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=sl -d postgres:13
|
||||||
|
@ -21,7 +15,7 @@ sleep 3
|
||||||
env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run alembic upgrade head
|
env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run alembic upgrade head
|
||||||
|
|
||||||
# generate the migration script.
|
# generate the migration script.
|
||||||
env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run alembic revision --autogenerate -m "$reason"
|
env DB_URI=postgresql://postgres:postgres@127.0.0.1:25432/sl poetry run alembic revision --autogenerate $@
|
||||||
|
|
||||||
# remove the db
|
# remove the db
|
||||||
docker rm -f ${container_name}
|
docker rm -f ${container_name}
|
||||||
|
|
Loading…
Reference in New Issue