mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-05 14:26:00 -04:00
#645 Avoid collisions by using a 20 character random string as a fallback
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user