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

User Roles does not appear to work locally #2472

Open
gpmarkyoung opened this issue Jan 18, 2024 · 9 comments
Open

User Roles does not appear to work locally #2472

gpmarkyoung opened this issue Jan 18, 2024 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@gpmarkyoung
Copy link

When running nhost locally via the CLI, user roles doesn't seem to populate.
image

However, the same installation online:
image

And the local nhost.toml contains:
image

And the local auth->roles contains:
image

The console has no errors in it, and it is sync'd with nhost.io.

@gpmarkyoung gpmarkyoung added the bug Something isn't working label Jan 18, 2024
@gpmarkyoung
Copy link
Author

discord "help" for reference: https://discord.com/channels/552499021260914688/1196488618886316174

@dbarrosop
Copy link
Contributor

dbarrosop commented Jan 19, 2024

Thanks for the report.

That is expected as that form is populated from the nhost.toml which the local dashboard can't read (yet). In the meantime you can manage roles in the database tab:

Screenshot 2024-01-19 at 07 50 30

Which should allow you to "mark requests as":

Screenshot 2024-01-19 at 07 51 05

@gpmarkyoung
Copy link
Author

The auth->user_roles table is empty, and locked so I cannot alter user roles. How then do I populate it?

@dbarrosop
Copy link
Contributor

dbarrosop commented Jan 20, 2024

🤦 that's a different bug, as a workaround of the workaround you can use the SQL editor:

Screenshot 2024-01-20 at 13 59 21

You could also use graphql mutations if you want:

mutation {
  insertAuthRole(object: {
		role: "some-other-role"
  }) {
    role
  }
}

mutation {
  insertAuthUserRole(object: {
    userId: "f8e2c4c6-6f8a-448a-b1cd-5070a4c90328"
		role: "some-other-role"
  }) {
    id
    userId
    role
  }
}

@dbarrosop dbarrosop self-assigned this Jan 29, 2024
@felixhagspiel
Copy link

felixhagspiel commented Mar 6, 2024

@dbarrosop what is the workflow for adding new roles until this is fixed?

  1. Manually add a new role on my local dev environment inside the auth.roles table & mark it as a migration
  2. Push the migration to prod
  3. As I understand, in the nhost dashboard the new role will not show in the auth tab after the deployment, so I have to manually create a new entry inside auth.user_roles

Is this the correct way?

@dbarrosop
Copy link
Contributor

You shouldn't create roles in the database directly. For adding new roles you need to add them to settings, either the toml under:

[auth.user.roles]
default = 'user'
allowed = ['user', 'me', 'some-new-role']

or in the dashboard->settings->Roles and permissions.

@felixhagspiel
Copy link

Can`t believe I have missed that, thanks

@felixhagspiel
Copy link

@dbarrosop If I do that, then users that sign up get the staff role automatically, which is not what I want. I want to set the staff role only for some users. I assume this is not possible via those checkboxes / settings, but only by manually creating an entry in schem.auth -> user_roles and not setting the role in ... allowed = [... 'some-new-role']?

@dbarrosop
Copy link
Contributor

Yes, that is correct. Apologies for the confusion. I thought you wanted a new default alowed role. If you just want the role for some users the procedure you described is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants