diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index 02b37ed84..fd1991042 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -38,9 +38,13 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController m.email = auth.info.email m.password = Devise.friendly_token[0,20] - # TODO This has a reasonable chance of collision + # First, try the nickname or friendly generate from the email m.login_name = auth.info.nickname || auth.info.email.split("@").first.gsub(/[^A-Za-z]+/, '_').underscore + # Do we have a collision with an existing account? Generate a 20 character long random name + # so the user can update it later + m.login_name = Devise.friendly_token[0,20] if Member.where(login_name: m.login_name).any? + m.skip_confirmation! # TODO Assess this later, if we introduce separate modelling for user photos