From 84987cd835ef2f488e0287daafe9591fa51de886 Mon Sep 17 00:00:00 2001 From: Einar Jonsson Date: Fri, 23 Aug 2013 09:38:01 +0000 Subject: [PATCH] Extracted nickname registration into a private controller method --- app/controllers/users_controller.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index bd309f1a2b0..17ac5028b1b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -162,11 +162,7 @@ class UsersController < ApplicationController user = User.new_from_params(params) auth = authenticate_user(user, params) - - if user.valid? && SiteSetting.call_discourse_hub? - DiscourseHub.register_nickname(user.username, user.email) - end - + register_nickname(user) if user.save activator = UserActivator.new(user, session, cookies) @@ -457,4 +453,10 @@ class UsersController < ApplicationController auth[:oauth2].is_a?(Hash) && auth[:oauth2][:provider] && auth[:oauth2][:uid] && Oauth2UserInfo.where(provider: auth[:oauth2][:provider], uid: auth[:oauth2][:uid]).empty? end + + def register_nickname(user) + if user.valid? && SiteSetting.call_discourse_hub? + DiscourseHub.register_nickname(user.username, user.email) + end + end end