Skip to content

Commit

Permalink
fix: update auth provider in email alerts (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
rohan-chaturvedi authored Oct 9, 2023
1 parent 3e38624 commit cc83ad3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions backend/api/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ def send_email(subject, recipient_list, template_name, context):
)


def send_login_email(request, email):
def send_login_email(request, email, provider):
user_agent = request.META.get('HTTP_USER_AGENT', 'Unknown')
ip_address = get_client_ip(request)
timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')

# Creating context dictionary
context = {
'auth': 'GitHub',
'auth': provider,
'email': email,
'ip': ip_address,
'user_agent': user_agent,
Expand Down
7 changes: 3 additions & 4 deletions backend/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def complete_login(self, request, app, token, response, **kwargs):
print(f"Error notifying Slack: {e}")

try:
send_login_email(request, email)
send_login_email(request, email, 'Google')
except Exception as e:
print(f"Error sending email: {e}")

Expand Down Expand Up @@ -137,7 +137,7 @@ def complete_login(self, request, app, token, **kwargs):
print(f"Error notifying Slack: {e}")

try:
send_login_email(request, email)
send_login_email(request, email, 'GitHub')
except Exception as e:
print(f"Error sending email: {e}")

Expand All @@ -158,7 +158,6 @@ class CustomGitLabOAuth2Adapter(OAuth2Adapter):
provider_base_url, provider_api_version)

def complete_login(self, request, app, token, response):
print('logging in')
response = requests.get(self.profile_url, params={
"access_token": token.token})
data = _check_errors(response)
Expand All @@ -175,7 +174,7 @@ def complete_login(self, request, app, token, response):
print(f"Error notifying Slack: {e}")

try:
send_login_email(request, email)
send_login_email(request, email, 'GitLab')
except Exception as e:
print(f"Error sending email: {e}")

Expand Down

0 comments on commit cc83ad3

Please sign in to comment.