From fdb46f4ef6f7a06efaea856156353f8315dc2409 Mon Sep 17 00:00:00 2001 From: John McCann Cunniff Jr Date: Fri, 2 Feb 2024 14:09:39 -0500 Subject: [PATCH] FIX handle no email github accounts --- api/anubis/views/public/auth.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api/anubis/views/public/auth.py b/api/anubis/views/public/auth.py index 5db046fc..524fdfdd 100644 --- a/api/anubis/views/public/auth.py +++ b/api/anubis/views/public/auth.py @@ -2,6 +2,7 @@ from urllib.parse import urlunparse from urllib.parse import quote +import json import requests from flask import Blueprint, make_response, redirect, request @@ -163,9 +164,12 @@ def public_github_oauth(): headers=github_api_headers, ).json() + # Display user info + logger.info(f'github_user_info = {json.dumps(github_user_info, indent=2)}') + + # Get minimal information for setting username github_username = github_user_info["login"].strip() name = github_user_info['name'].strip() - email = github_user_info['email'].strip() # If user exists if current_user is not None: @@ -182,6 +186,9 @@ def public_github_oauth(): # If user didn't already exist, we need to create one if user is None: + # Grab email to use as netid + email = github_user_info['email'].strip() + # Create user user = User( netid=email,