Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 18, 2025

The documentation showed AuthUsers.update() as a static method call, causing "cannot be called from static context" errors when users followed the examples.

Changes

  • Updated code examples to use AuthServices.instance.authUsers.update() instead of AuthUsers.update()
  • Corrected method description from "AuthUsers class's updateUserScopes method" to "update method from AuthServices.instance.authUsers"
  • Applied fix across all 3.x.x documentation versions (main, 3.1.0, 3.0.0)

Example

// Before (incorrect)
await AuthUsers.update(session, authUserId: authUserId, scopes: {Scope.admin});

// After (correct)
await AuthServices.instance.authUsers.update(
  session,
  authUserId: authUserId,
  scopes: {Scope.admin},
);
Original prompt

This section details on the original issue you should resolve

<issue_title>Cannot update the scopes in the new auth model.</issue_title>
<issue_description>### Describe the bug

I am upgrading to the new auth module but I am stuck in updating scopes. Either the documentation is incorrect or there is a bug in the authusers object.

To reproduce

Try to use the example code in the docs: https://docs.serverpod.dev/concepts/authentication/basics .

await AuthUsers.update(
        session,
        authUserId: userId,
        scopes: 
           {
                OrganisationScope.organisationUser,
              },
      );

observe the error update cannot be called from static context

Expected behavior

I could update the scope on the AuthUsers ubject

Library version

3.1.1.

Platform information

Serverpod 3.1.1

Additional context

No response

How experienced are you with this library?

None

Are you interested in working on a PR for this?

  • I want to work on this</issue_description>

<agent_instructions>Please update the documentation to reflect this change. Update this for all 3.x.x versions of the documentation.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@SandPod Hey @remonh87!

The documentation is invalid, sorry for the. The correct way to update the scopes is to use AuthServices.instance.authUsers.update(session, authUserId: authUserId, ...);.

Where this is the signature of the method:

 Future<AuthUserModel> update(
    final Session session, {
    required final UuidValue authUserId,
    final Set<Scope>? scopes,
    final bool? blocked,
    final Transaction? transaction,
  }) async {

I'll update the documentation to reflect this.</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: SandPod <137198655+SandPod@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix scope update issue in new auth model Fix AuthUsers.update() documentation for 3.x.x versions Dec 18, 2025
Copilot AI requested a review from SandPod December 18, 2025 08:10
Copy link
Contributor

@SandPod SandPod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖

@SandPod SandPod marked this pull request as ready for review December 18, 2025 08:15
@SandPod SandPod requested a review from a team December 18, 2025 08:15
@SandPod SandPod changed the title Fix AuthUsers.update() documentation for 3.x.x versions fix: AuthUsers.update() documentation for 3.x.x versions Dec 18, 2025
@SandPod SandPod merged commit 3889a21 into main Dec 18, 2025
4 of 7 checks passed
@SandPod SandPod deleted the copilot/fix-auth-model-scope-update branch December 18, 2025 09:01
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.

Cannot update the scopes in the new auth model.

3 participants