app/controllers/auth_controller.rb
# log in/out index page
log in/out index page
log in / out index page
def index
    all_providers = OmniAuth::Builder.providers
    logged_in_providers = @users.find_all { |user| !user.dummy_user? }.collect { |user| user.provider }
    @providers = []
    all_providers.each do |provider|
      logged_in = case
                    when !logged_in_providers.index(provider) then
                      0 
                    when logged_in_providers.length == 1 then
                      1 
                    else
                      2 
                  end 
      if logged_in == 0
        access = 0
      else
        access = 2
      end
      post_on_wall = true
      @providers << [provider, logged_in, access, post_on_wall]
    end 
    @providers = @providers.sort_by { |a| provider_camelize(a) }
  end
def index all_providers = OmniAuth :: Builder . providers logged_in_providers = @users . find_all { | user | ! user . dummy_user? } . collect { | user | user . provider } @providers = [ ] all_providers . each do | provider | logged_in = case when ! logged_in_providers . index ( provider ) then 0 when logged_in_providers . length == 1 then 1 else 2 end if logged_in == 0 access = 0 else access = 2 end post_on_wall = true @providers << [ provider , logged_in , access , post_on_wall ] end @providers = @providers . sort_by { | a | provider_camelize ( a ) } end
log in/out index page
log in / out index page
# initialize @providers hash with true/false to logged in provider # logged_in: 0 not connected, 1 connected with one login provider, 2 connected with multiple login providers # not logged in - log in link # logged in with one login provider - log out link and return to login provider # logged in with multiple login providers - log out link and stay on auth/index page # case # access; 0 not connected, 2 read+write access # each provider