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

fix: disable retired users on oauth login #53

Merged
merged 1 commit into from
Jan 12, 2024
Merged
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
18 changes: 17 additions & 1 deletion LedenAdministratie/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DJOOAuth2Validator(OAuth2Validator):

# This needs to be without the 'request' parameter + lambda's to support claim discovery
# pylint: disable=arguments-differ
def get_additional_claims(self):
def get_additional_claims(self) -> dict:
return {
"given_name": lambda request: request.user.first_name,
"family_name": lambda request: request.user.last_name,
Expand All @@ -34,3 +34,19 @@ def get_additional_claims(self):
if request.user.member.active_stripcard
else None,
}

def validate_user(
self, username, password, client, request, *args, **kwargs
) -> bool:
if not super().validate_user(
username, password, client, request, *args, **kwargs
):
# User doesn't exist or is not active
return False
# User exists and is active, now check the end date of the linked Member
if request.user.member.is_active():
return True
# User end date has passed -> disable
request.user.active = False
request.user.save()
return False
Loading