-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a preferred email option in account settings (Fixes #408) #440
Merged
+227
−78
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...c/appointment/migrations/versions/2024_05_28_1745-9fe08ba6f2ed_update_subscribers_add_.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""update subscribers add preferred_email | ||
|
||
Revision ID: 9fe08ba6f2ed | ||
Revises: 89e1197d980d | ||
Create Date: 2024-05-28 17:45:48.192560 | ||
|
||
""" | ||
import os | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy_utils import StringEncryptedType | ||
from sqlalchemy_utils.types.encrypted.encrypted_type import AesEngine | ||
|
||
|
||
def secret(): | ||
return os.getenv("DB_SECRET") | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '9fe08ba6f2ed' | ||
down_revision = '89e1197d980d' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.add_column('subscribers', sa.Column('secondary_email', StringEncryptedType(sa.String, secret, AesEngine, "pkcs5", length=255), nullable=True, index=True)) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_column('subscribers', 'secondary_email') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ def test_update_me(self, with_db, with_client): | |
"username": "test", | ||
"name": "Test Account", | ||
"timezone": "Europe/Berlin", | ||
"secondary_email": "[email protected]" | ||
}, | ||
headers=auth_headers, | ||
) | ||
|
@@ -20,21 +21,17 @@ def test_update_me(self, with_db, with_client): | |
assert data["username"] == "test" | ||
assert data["name"] == "Test Account" | ||
assert data["timezone"] == "Europe/Berlin" | ||
|
||
# Can't test login right now | ||
|
||
# response = client.get("/login", headers=headers) | ||
# data = response.json() | ||
# assert data["username"] == "test" | ||
# assert data["name"] == "Test Account" | ||
# assert data["timezone"] == "Europe/Berlin" | ||
# Response returns preferred_email | ||
assert data["preferred_email"] == "[email protected]" | ||
|
||
# Confirm the data was saved | ||
with with_db() as db: | ||
subscriber = repo.subscriber.get_by_email(db, os.getenv('TEST_USER_EMAIL')) | ||
assert subscriber.username == "test" | ||
assert subscriber.name == "Test Account" | ||
assert subscriber.timezone == "Europe/Berlin" | ||
assert subscriber.secondary_email == "[email protected]" | ||
assert subscriber.preferred_email == "[email protected]" | ||
|
||
def test_signed_short_link(self, with_client): | ||
"""Retrieves our unique short link, and ensures it exists""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should ensure there's no duplicates if they already have their preferred email set as their main email, or a google account email.