mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-02-18 14:48:24 -05:00
Refactor to a method to DRY, even if its not 100% the best spot for it to live long term
This commit is contained in:
@@ -7,16 +7,7 @@ class AuthenticationsController < ApplicationController
|
||||
auth = request.env['omniauth.auth']
|
||||
@authentication = nil
|
||||
if auth
|
||||
|
||||
name = ''
|
||||
case auth['provider']
|
||||
when 'twitter'
|
||||
name = auth['info']['nickname']
|
||||
when 'flickr', 'facebook'
|
||||
name = auth['info']['name']
|
||||
else
|
||||
name = auth['info']['name']
|
||||
end
|
||||
name = Growstuff::OauthSignupAction.new.determine_name(auth)
|
||||
|
||||
@authentication = current_member.authentications
|
||||
.create_with(
|
||||
|
||||
@@ -38,15 +38,7 @@ class Growstuff::OauthSignupAction
|
||||
# - We need to create it
|
||||
#
|
||||
def establish_authentication(auth, member)
|
||||
name = ''
|
||||
case auth['provider']
|
||||
when 'twitter'
|
||||
name = auth['info']['nickname']
|
||||
when 'flickr', 'facebook'
|
||||
name = auth['info']['name']
|
||||
else
|
||||
name = auth['info']['name']
|
||||
end
|
||||
name = determine_name(auth)
|
||||
|
||||
authentication = member.authentications
|
||||
.create_with(
|
||||
@@ -67,4 +59,18 @@ class Growstuff::OauthSignupAction
|
||||
def member_created?
|
||||
@member_created
|
||||
end
|
||||
|
||||
def determine_name(auth)
|
||||
name = ''
|
||||
case auth['provider']
|
||||
when 'twitter'
|
||||
name = auth['info']['nickname']
|
||||
when 'flickr', 'facebook'
|
||||
name = auth['info']['name']
|
||||
else
|
||||
name = auth['info']['name']
|
||||
end
|
||||
|
||||
name
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user