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: update auth provider in email alerts #70

Merged
merged 1 commit into from
Oct 9, 2023
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
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
Loading