From ea59092d69efd7f9a50a08b8f4910d46c3a0e546 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Feb 2026 02:48:18 +0000 Subject: [PATCH 1/4] Initial plan From cca8151d6e22378a89d93bbbdc9a74a79105de5d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Feb 2026 02:56:05 +0000 Subject: [PATCH 2/4] Add multi-auth support: GitHub/Google OAuth, optional email registration, hide admin nav - Add django-allauth for GitHub and Google OAuth authentication - Create custom RegistrationForm with optional email field and recovery warning - Update login/register templates with OAuth buttons and clear UI sections - Remove Django admin link from navigation (still accessible via /admin/ URL) - Update home page to link to course creation instead of admin - Configure allauth settings, backends, middleware in settings.py - Add OAuth credential placeholders to .env.example - Add 16 new tests covering auth forms, views, OAuth buttons, admin visibility Co-authored-by: coreysreid <111491611+coreysreid@users.noreply.github.com> --- .env.example | 8 ++ requirements.txt | 1 + study/forms.py | 16 +++ study/templates/study/base.html | 1 - study/templates/study/home.html | 2 +- study/templates/study/login.html | 21 ++++ study/templates/study/register.html | 33 +++++- study/test_auth.py | 153 ++++++++++++++++++++++++++++ study/views.py | 8 +- study_platform/settings.py | 42 ++++++++ study_platform/urls.py | 1 + 11 files changed, 278 insertions(+), 8 deletions(-) create mode 100644 study/test_auth.py diff --git a/.env.example b/.env.example index 141a969..814299e 100644 --- a/.env.example +++ b/.env.example @@ -2,3 +2,11 @@ SECRET_KEY=your-secret-key-here DEBUG=True ALLOWED_HOSTS=localhost,127.0.0.1 GITHUB_REPO=owner/repo-name + +# OAuth providers (optional - leave empty to disable) +# GitHub: https://github.com/settings/applications/new +GITHUB_OAUTH_CLIENT_ID= +GITHUB_OAUTH_SECRET= +# Google: https://console.developers.google.com/apis/credentials +GOOGLE_OAUTH_CLIENT_ID= +GOOGLE_OAUTH_SECRET= diff --git a/requirements.txt b/requirements.txt index 296458c..749e0e6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ numpy>=1.24.0 RestrictedPython>=6.0 dj-database-url>=2.0.0 psycopg2-binary>=2.9.0 +django-allauth>=65.0.0 diff --git a/study/forms.py b/study/forms.py index fcac5c0..091f72a 100644 --- a/study/forms.py +++ b/study/forms.py @@ -1,6 +1,22 @@ from django import forms +from django.contrib.auth.forms import UserCreationForm +from django.contrib.auth.models import User from .models import Course, Topic, Flashcard, CardFeedback, Skill + +class RegistrationForm(UserCreationForm): + """Custom registration form with optional email and privacy warning.""" + email = forms.EmailField( + required=False, + widget=forms.EmailInput(attrs={'class': 'form-control', 'placeholder': 'Optional email address'}), + help_text='Optional. Providing an email allows password recovery. Without it, there is no way to reset a forgotten password.', + ) + + class Meta: + model = User + fields = ['username', 'email', 'password1', 'password2'] + + class CourseForm(forms.ModelForm): class Meta: model = Course diff --git a/study/templates/study/base.html b/study/templates/study/base.html index 7504a83..b678b4b 100644 --- a/study/templates/study/base.html +++ b/study/templates/study/base.html @@ -240,7 +240,6 @@

📚 Study Platform

{% if user.is_staff %}
  • Feedback Review
  • {% endif %} -
  • Admin
  • {% csrf_token %} diff --git a/study/templates/study/home.html b/study/templates/study/home.html index b91fe14..1d6cd17 100644 --- a/study/templates/study/home.html +++ b/study/templates/study/home.html @@ -28,7 +28,7 @@

    📝 Study Sessions

    🎯 Quick Start

    Jump into studying

    - Manage Content + Create Course
    diff --git a/study/templates/study/login.html b/study/templates/study/login.html index 975c9ee..fc9ee33 100644 --- a/study/templates/study/login.html +++ b/study/templates/study/login.html @@ -1,4 +1,5 @@ {% extends 'study/base.html' %} +{% load socialaccount %} {% block title %}Login - Study Platform{% endblock %} @@ -6,6 +7,26 @@

    Login

    + +
    +

    Sign in with a social account

    +
    + + + Sign in with GitHub + + + + Sign in with Google + +
    +
    + +
    +
    + or sign in with username +
    + {% csrf_token %} diff --git a/study/templates/study/register.html b/study/templates/study/register.html index 7af9d68..cb759dc 100644 --- a/study/templates/study/register.html +++ b/study/templates/study/register.html @@ -1,4 +1,5 @@ {% extends 'study/base.html' %} +{% load socialaccount %} {% block title %}Register - Study Platform{% endblock %} @@ -6,6 +7,26 @@

    Register

    + +
    +

    Sign up with a social account

    + +
    + +
    +
    + or register with username +
    + {% csrf_token %} @@ -33,6 +54,14 @@

    Register< {% endif %}

    {% endfor %} + + +
    + ⚠️ No email? +

    + If you do not provide an email address, there will be no way to recover your password if forgotten. +

    +
    @@ -43,7 +72,7 @@

    Register<