RocketChat / RocketChat/Rocket.Chat
First login over custom OAuth - User missing "user" role for some time
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Description:
If a new user logs in the first time over OAuth the user Is not able to login directly. It stays on the login page.
In RocketChat the user gets created instantly what I can see in the Users Settings.
But the user is missing the "user" role.
After a few Minutes the role appers magically mapped to the user. In the debug log it looks like it happens when this job runs:
"level":20,"time":"2022-12-29T12:47:42.923Z","pid":1,"hostname":"rocketchat-8c5cb675d-h9xwl","name":"Callbacks","msg":"Executing callback with id 2fa for hook onValidateLogin"}
{"level":20,"time":"2022-12-29T12:47:43.060Z","pid":1,"hostname":"rocketchat-8c5cb675d-h9xwl","name":"Callbacks","msg":"Executing callback with id Dqaxxxxa for hook afterValidateLogin"}
When the role is then assigned - the user can finally login.
2nd factor auth is disabled in the configuration.
Steps to reproduce:
- login over OAuth the first time
- user gets created but role is missing (see screenshot)
- wait
- when the role is assigned - login
Expected behavior:
- login over OAuth the first time and be logged in ;)
Actual behavior:

Server Setup Information:
- Version of Rocket.Chat Server: 5.4.1
- Operating System: Official RocketChat container image
- Deployment Method: K8s / Openshift
- Number of Running Instances: 1
- DB Replicaset Oplog:
- NodeJS Version: v14.19.3
- MongoDB Version: 6.0.3
Client Setup Information
- Browser Version: Chromium 105.0.5195.125
Relevant logs:
"level":20,"time":"2022-12-29T12:47:42.923Z","pid":1,"hostname":"rocketchat-8c5cb675d-h9xwl","name":"Callbacks","msg":"Executing callback with id 2fa for hook onValidateLogin"}
{"level":20,"time":"2022-12-29T12:47:43.060Z","pid":1,"hostname":"rocketchat-8c5cb675d-h9xwl","name":"Callbacks","msg":"Executing callback with id Dqaxxxxa for hook afterValidateLogin"}
There are no logs about a failed login - nothing seems wrong beside the missing role :(
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the OAuth first-login flow and the onValidateLogin and afterValidateLogin callbacks shown in the logs. Reproduce the first OAuth login and trace when the user role is assigned; done means the new user receives the role and is logged in immediately without waiting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- authentication, authorization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100