Skip to content

Conversation

@bokelley
Copy link
Contributor

Summary

Fixes "Access denied" error for super admin users (e.g., bokelley@scope3.com) logging in via Google OAuth.

Problem

Super admin users successfully authenticated via OAuth but then got "Access denied" when the app tried to redirect them to the admin interface.

Root Cause

The OAuth callback set session["is_super_admin"] = True but didn't set session["role"] = "super_admin".

The index route (core.py:88) checks for:

if session.get("role") == "super_admin":

So super admins would fail this check and hit the access denied path.

Fix

Added session["role"] = "super_admin" when authenticating super admin users via OAuth, matching the pattern used in the test user login path (auth.py:385):

# Check if user is super admin
if email_domain == "scope3.com" or is_super_admin(email):
    session["is_super_admin"] = True
    session["role"] = "super_admin"  # ← Added this line
    flash(f"Welcome {user.get('name', email)}! (Super Admin)", "success")
    return redirect(url_for("core.index"))

Testing

  • ✅ Super admin OAuth login now works correctly
  • ✅ Redirects to tenant list page (index.html)
  • ✅ Regular tenant users still work as before

Related

🤖 Generated with Claude Code

**Issue**: Super admin users (e.g., bokelley@scope3.com) logging in via
OAuth got "Access denied" error when trying to access the admin interface.

**Root Cause**: The OAuth callback set `session["is_super_admin"] = True`
but didn't set `session["role"] = "super_admin"`. The index route
(core.py:88) checks for `session.get("role") == "super_admin"`, so
super admins would fail this check and hit the access denied path.

**Fix**: Add `session["role"] = "super_admin"` when authenticating
super admin users via OAuth, matching the pattern used in the test
user login path (auth.py:385).

**Testing**: Super admin OAuth login now works correctly and redirects
to the tenant list page.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@bokelley bokelley merged commit 505b24f into main Oct 28, 2025
9 checks passed
danf-newton pushed a commit to Newton-Research-Inc/salesagent that referenced this pull request Nov 24, 2025
)

**Issue**: Super admin users (e.g., bokelley@scope3.com) logging in via
OAuth got "Access denied" error when trying to access the admin interface.

**Root Cause**: The OAuth callback set `session["is_super_admin"] = True`
but didn't set `session["role"] = "super_admin"`. The index route
(core.py:88) checks for `session.get("role") == "super_admin"`, so
super admins would fail this check and hit the access denied path.

**Fix**: Add `session["role"] = "super_admin"` when authenticating
super admin users via OAuth, matching the pattern used in the test
user login path (auth.py:385).

**Testing**: Super admin OAuth login now works correctly and redirects
to the tenant list page.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants