Skip to content

Commit

Permalink
simpler find_or_create by
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienpoly committed Sep 10, 2024
1 parent 56a91c0 commit 9e05d60
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/controllers/sessions/omniauth_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ def create
connected_account = ConnectedAccount.find_or_initialize_by(provider: omniauth.provider, uid: omniauth.uid)

if connected_account.new_record?
@user = User.create_with(user_params).find_or_create_by(email: omniauth.info.email)
@user = User.find_or_create_by(email: omniauth.info.email) do |user|
user.password = SecureRandom.base58
user.verified = true
end
connected_account.user = @user
connected_account.access_token = omniauth.credentials&.try(:token)
connected_account.username = omniauth.info&.try(:nickname)
Expand Down

0 comments on commit 9e05d60

Please sign in to comment.