From c7697bbae26d27cdfff4bf7868040977407ff730 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 11 Jul 2013 16:02:18 +1000 Subject: [PATCH] remove duplicate code --- .../users/omniauth_callbacks_controller.rb | 56 ++++++++----------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index e552691b3cc..6e60810752c 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -60,22 +60,7 @@ class Users::OmniauthCallbacksController < ApplicationController auth_provider: "Twitter" } - if user_info - if user_info.user.active? - if Guardian.new(user_info.user).can_access_forum? - log_on_user(user_info.user) - @data[:authenticated] = true - else - @data[:awaiting_approval] = true - end - else - @data[:awaiting_activation] = true - # send another email ? - end - else - @data[:name] = screen_name - end - + process_user_info(user_info, screen_name) end def create_or_sign_on_user_using_facebook(auth_token) @@ -265,24 +250,7 @@ class Users::OmniauthCallbacksController < ApplicationController auth_provider: "Github" } - if user_info - if user_info.user.active? - - if Guardian.new(user_info.user).can_access_forum? - log_on_user(user_info.user) - @data[:authenticated] = true - else - @data[:awaiting_approval] = true - end - - else - @data[:awaiting_activation] = true - # send another email ? - end - else - @data[:name] = screen_name - end - + process_user_info(user_info, screen_name) end def create_or_sign_on_user_using_persona(auth_token) @@ -319,6 +287,26 @@ class Users::OmniauthCallbacksController < ApplicationController private + def process_user_info(user_info, screen_name) + if user_info + if user_info.user.active? + + if Guardian.new(user_info.user).can_access_forum? + log_on_user(user_info.user) + @data[:authenticated] = true + else + @data[:awaiting_approval] = true + end + + else + @data[:awaiting_activation] = true + # send another email ? + end + else + @data[:name] = screen_name + end + end + def invite_only? SiteSetting.invite_only? && !@data[:authenticated] end