Skip to content

Commit

Permalink
Merge pull request #3486 from WikiWatershed/tt/fix-concord-login
Browse files Browse the repository at this point in the history
Connects #3467
  • Loading branch information
rajadain authored Feb 24, 2022
2 parents 4b82f10 + f5f990c commit a65680c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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

0 comments on commit a65680c

Please sign in to comment.