Skip to content
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

Unset phone or email by updating it with null #117

Merged
merged 4 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Breaking changes
- Endpoint for updating custom tenant data changed (#98, PLUM Sprint 221104)
- Unset credential phone/email by setting it to null instead of empty string (#117, PLUM Sprint 221104)

### Fix
- Logout with ID token (#116, PLUM Sprint 221104)
Expand All @@ -19,6 +20,7 @@
### Refactoring
- Keep superuser role after provisioning (#102, PLUM Sprint 221021)
- Endpoint for updating custom tenant data changed (#98, PLUM Sprint 221104)
- Unset credential phone/email by setting it to null instead of empty string (#117, PLUM Sprint 221104)

---

Expand Down
10 changes: 4 additions & 6 deletions seacatauth/credentials/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,17 @@
"description": "Username",
},
"email": {
"type": "string",
"description": "Email address",
"anyOf": [
{"format": "email"},
{"const": ""},
{"type": "null"},
{"type": "string", "format": "email"},
],
},
"phone": {
"type": "string",
"description": "Mobile number",
"anyOf": [
{"pattern": r"^\+?[0-9 ]+$"},
{"const": ""},
{"type": "null"},
{"type": "string", "pattern": r"^\+?[0-9 ]+$"},
],
},
"data": {
Expand Down
12 changes: 6 additions & 6 deletions seacatauth/credentials/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,16 +413,16 @@ async def update_credentials(self, credentials_id: str, update_dict: dict, sessi
raise asab.exceptions.ValidationError(
"Cannot unsuspend credential whose registration has not been completed.")

if "email" in update_dict and update_dict["email"] == "":
email_specified = False
elif "email" not in current_dict or current_dict["email"] == "":
if "email" in update_dict:
email_specified = update_dict["email"] is not None
elif "email" not in current_dict or current_dict["email"] is None:
email_specified = False
else:
email_specified = True

if "phone" in update_dict and update_dict["phone"] == "":
phone_specified = False
elif "phone" not in current_dict or current_dict["phone"] == "":
if "phone" in update_dict:
phone_specified = update_dict["phone"] is not None
elif "phone" not in current_dict or current_dict["phone"] is None:
phone_specified = False
else:
phone_specified = True
Expand Down