-
Notifications
You must be signed in to change notification settings - Fork 8
[Social Work] - Deactivate Staff accounts after 60 days of inactivity #1829
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
Open
landonshumway-ia
wants to merge
23
commits into
csg-org:main
Choose a base branch
from
InspiringApps:feat/sw-staff-user-inactive-notifications
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
164f861
Add 'lastLoginAt' field to staff user schemas
landonshumway-ia 5ed7915
Add data class for staff user data
landonshumway-ia 43f0dec
Add client method to record login timestamp
landonshumway-ia 047e5ab
Add hook to update login timestamp to token generation lambda
landonshumway-ia a4b026c
Add method to list all staff users for a compact
landonshumway-ia 4dae80a
Add method to deactivate staff user
landonshumway-ia 47ad46f
Add logic/permission to re-enable user in re-invite flow
landonshumway-ia bbafb66
Add staff user directory class for finding compact/jurisdiction admins
landonshumway-ia 80ae602
Add handler for checking inactive staff users
landonshumway-ia 49f7ca7
Add email notification for staff user inactivity
landonshumway-ia 85e4dfd
Add stack for processing staff user inactivity tracking
landonshumway-ia 7b15a6a
Filter inactive admins from receiving notifications
landonshumway-ia ee975ca
Add error log alert for pre-token generation lambda
landonshumway-ia a8d5663
Send notification the last day before deactivation
landonshumway-ia 22fec07
Do not send notification the day of deactivation
landonshumway-ia 9488057
Fix comment
landonshumway-ia 4335344
update dateOfUpdate when deactivating user
landonshumway-ia d3486b8
Add smoke tests for deactivation notifications
landonshumway-ia 46b7fe5
Set dateOfUpdate when staff user permissions or attributes modified
landonshumway-ia 42a737b
update nanoid version for node check
landonshumway-ia 4ab179d
Bold date in email notification based on client feedback
landonshumway-ia 6dc445b
Add error log alert for inactivity lambda
landonshumway-ia 36a5af9
PR feedback - clarify comments and tests
landonshumway-ia 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,70 @@ | ||
| # ruff: noqa: N802 we use camelCase to match the marshmallow schema definition | ||
|
|
||
| from datetime import datetime | ||
| from uuid import UUID | ||
|
|
||
| from cc_common.data_model.schema.common import CCDataClass, CCPermissionsAction | ||
| from cc_common.data_model.schema.user.record import UserRecordSchema | ||
|
|
||
|
|
||
| class StaffUserData(CCDataClass): | ||
| """ | ||
| Class representing a Staff User with getters for all properties. | ||
| """ | ||
|
|
||
| # Define record schema at the class level | ||
| _record_schema = UserRecordSchema() | ||
|
|
||
| # Require valid data when creating instances | ||
| _requires_data_at_construction = True | ||
|
|
||
| @property | ||
| def userId(self) -> UUID: | ||
| return self._data['userId'] | ||
|
|
||
| @property | ||
| def compact(self) -> str: | ||
| return self._data['compact'] | ||
|
|
||
| @property | ||
| def status(self) -> str: | ||
| return self._data['status'] | ||
|
|
||
| @property | ||
| def lastLoginAt(self) -> datetime | None: | ||
| """Absent for users who have not signed in since login tracking was introduced.""" | ||
| return self._data.get('lastLoginAt') | ||
|
|
||
| # The attributes field is flattened here, since its nesting is a storage detail | ||
| @property | ||
| def email(self) -> str: | ||
| return self._data['attributes']['email'] | ||
|
|
||
| @property | ||
| def givenName(self) -> str: | ||
| return self._data['attributes']['givenName'] | ||
|
|
||
| @property | ||
| def familyName(self) -> str: | ||
| return self._data['attributes']['familyName'] | ||
|
|
||
| @property | ||
| def compactActions(self) -> set[str]: | ||
| """Compact-level actions. Empty if the user only has jurisdiction permissions.""" | ||
| return self._data['permissions'].get('actions', set()) | ||
|
|
||
| @property | ||
| def jurisdictions(self) -> set[str]: | ||
| """Jurisdiction codes where this user holds any permission.""" | ||
| return set(self._data['permissions']['jurisdictions'].keys()) | ||
|
|
||
| def jurisdictionActions(self, jurisdiction: str) -> set[str]: | ||
| """The user's actions in one jurisdiction. Empty if they hold no permissions there.""" | ||
| return self._data['permissions']['jurisdictions'].get(jurisdiction, set()) | ||
|
|
||
| @property | ||
| def isCompactAdmin(self) -> bool: | ||
| return CCPermissionsAction.ADMIN in self.compactActions | ||
|
|
||
| def isJurisdictionAdmin(self, jurisdiction: str) -> bool: | ||
| return CCPermissionsAction.ADMIN in self.jurisdictionActions(jurisdiction) |
This file contains hidden or 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 hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.