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 Concord Login #3486

Merged
merged 3 commits into from
Feb 24, 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
5 changes: 3 additions & 2 deletions src/mmw/apps/user/backends.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.auth.backends import BaseBackend
from django.contrib.auth.models import User

from apps.user.models import ItsiUser, ConcordUser


class SSOAuthenticationBackend(object):
class SSOAuthenticationBackend(BaseBackend):
"""
A custom authentication back-end for Single Sign On providers.

Expand All @@ -20,7 +21,7 @@ def __init__(self, model, field):
self.SSOUserModel = model
self.SSOField = field

def authenticate(self, sso_id=None):
def authenticate(self, request=None, sso_id=None):
if sso_id is not None:
try:
query = {self.SSOField: sso_id}
Expand Down
6 changes: 5 additions & 1 deletion src/mmw/apps/user/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,11 @@ def concord_auth(request):
concord_user = session.get_user()
except Exception as e:
# Report OAuth error
rollbar.report_message(f'Concord OAuth Error: {e.message}', 'error')
message = 'Concord OAuth Error'
if hasattr(e, 'message'):
message += f': {e.message}'

rollbar.report_message(message, 'error')
return redirect('/error/sso')

user = authenticate(sso_id=concord_user['id'])
Expand Down