-
Notifications
You must be signed in to change notification settings - Fork 2
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
Consider email colisions on omniauth-idmty #149
Comments
Let's try to merge the accounts. 🙂 |
@basicavisual , the patch introduced on #148 fixed the "duplicated account" problem. Now the transaction has enough information (i.e. transaction do
create_or_find_user
@identity = create_identity
end And just creating an identity for the user (associated with the OAuth provider). This will enable the transition from Decidim's registration to IDMty. The only problem is that the controller doesn't recognize that the user already had an account, so it asks again for the name and the alias (this is a bad). I'm thinking to patch the following method 2: def user_params_from_oauth_hash
return nil if oauth_data.empty?
{
provider: oauth_data[:provider],
uid: oauth_data[:uid],
name: oauth_data[:info][:name],
nickname: oauth_data[:info][:nickname],
oauth_signature: OmniauthRegistrationForm.create_signature(oauth_data[:provider], oauth_data[:uid]),
avatar_url: oauth_data[:info][:image],
raw_data: oauth_hash
}
end To search for a user and plug the name and nickname. def user_params_from_oauth_hash
return nil if oauth_data.empty?
+ email = oauth_data.dig(:info, :email)
+ user = Decidim::User.find_by(email: email, organization: current_organization)
{
provider: oauth_data[:provider],
uid: oauth_data[:uid],
+ name: oauth_data[:info][:name] || user&.name,
+ nickname: oauth_data[:info][:nickname] || user&.nickname,
oauth_signature: Decidim::OmniauthRegistrationForm.create_signature(oauth_data[:provider], oauth_data[:uid]),
avatar_url: oauth_data[:info][:image],
raw_data: oauth_hash
}
end Now, this works. 🙂 Footnotes |
Thank you @samanera ! very clean solution. this works as expected :) |
As a user, if my email was already registered on Decidimos Monterrey, and I create an account with IDMty that has the same email, I get a flash alert but it allows me to continue.
In this case I should either:
The text was updated successfully, but these errors were encountered: