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

Login with CAS gives me : "Username already exists." #3379

Closed
anthony-o opened this issue May 27, 2016 · 11 comments
Closed

Login with CAS gives me : "Username already exists." #3379

anthony-o opened this issue May 27, 2016 · 11 comments

Comments

@anthony-o
Copy link

Your Rocket.Chat version: 0.31.0

I've enabled CAS on my Rocket.Chat. This instance was created with v0.21.0 and my user was the first one to be created and the admin.

If I try to login with CAS, I've got "Username already exists." error message and I stay on login screen.
But other users don't have that problem: they can correctly manage to login with the CAS button.

@konsumate
Copy link
Contributor

This seems to happen when RocketChat accounts were created before 6b5565a
The way how user are identified/looked up changed with that patch.

Short fix if you can live with the consequences for now:
remove the affected users by RocketChat admin account, the user will be recreated correctly when authenticating next time with CAS sso.

@anthony-o
Copy link
Author

But if I remove this user, all his posts will be deleted?
Is there any way I can go throughout this bug by accessing the database and modifying some fields of some entity?

@konsumate
Copy link
Contributor

konsumate commented Sep 28, 2016

That's the downside of deleting the user.

Of course you can edit the user directly in the database by using meteor shell and update the user record:

var username = 'yourusername';
var myuser = Meteor.users.findOne({ 'username': username });
Meteor.users.update(myuser, { $set: { services: { cas: { external_id: username } } } });

Edit: A possible solution by doing a server-side check and upgrade the user is possible, but that could lead to unwanted modifications to Users which are not CAS created users e.g: in an environment where CAS is not the only user creating module.

@anthony-o
Copy link
Author

Great I accessed the mongodb server directly (because I was unable to find meteor binary on the rocketchat/rocket.chat:0.41.0 docker image) and added the cas field to the services and it worked, thanks !

@konsumate
Copy link
Contributor

For future reference, use something with docker like this:

docker exec -ti rocketchat_rocketchat_1 bash
root@61dec02b0979:/app# meteor shell

@anthony-o
Copy link
Author

After being connected to the rocketchat container (via docker exec -it rocketchat_rocketchat_1 bash), I'm still unable to execute that command:

rocketchat@3e128192d649:/app/bundle$ cd ..
rocketchat@3e128192d649:/app$ meteor shell
bash: meteor: command not found

@konsumate
Copy link
Contributor

@anthony-o This issue can be closed?

@rbabaee
Copy link

rbabaee commented Aug 20, 2018

I have installed rocketchat with snap, how can I run those commands?

@domenicocosta
Copy link

Hi,

i have installed in my local machine a server RC and i have to sincronize user via CAS, but i am obbliged to leave the checkbox "Registration with Authentication Services" to true, because in your record user exist the services json for cas.

"services": {
"cas": {
"external_id": "******",
"version": 1,
"attrs": {}
},
"resume": {
"loginTokens": [{
"when": ISODate("2019-02-13T20:12:08.473Z"),
"hashedToken": "JIfnasKSEOzEh1UWhUAmsIgaEOo9R2lFX1ijGBQuF2Q="
}]
}
},

For my purpose i create the user via rest api and next to access in rocket chat via CAS, but with the checkbox setting in true i have the error "User Exist...", it's possible to carry out an update to the record user with the services cas and check the first via CAS and the next via Password.

It's presumibile resolve this issue in this mode?

Thanks

Best regards

@bseclier
Copy link

bseclier commented Jul 8, 2020

Hello, I don't understand why this issue is closed, I still have the problem here (v3.4.1).
Was someone be able to create a user with the API and, then, connect with this user thanks to CAS without have the "username already exists" ?

Thanks for your help.

@bseclier
Copy link

A fix was added to the fix, it works perfectly now (3.4.2).
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants