From 2c0959e8164d69fc6b182cef7cc4fd800e418715 Mon Sep 17 00:00:00 2001 From: Kashiftariq1997 Date: Fri, 23 Jan 2026 21:54:15 +0500 Subject: [PATCH] Fixed name update issue --- app/controllers/sso_login_controller.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/sso_login_controller.rb b/app/controllers/sso_login_controller.rb index 0d2d7339..9bd11f62 100644 --- a/app/controllers/sso_login_controller.rb +++ b/app/controllers/sso_login_controller.rb @@ -82,10 +82,16 @@ class SsoLoginController < ApplicationController end end - # Update user info if provided and different + # Don't update name from SSO token for existing users + # This preserves user's manually updated profile information + # Only update if name fields are empty (initial setup) update_attrs = {} - update_attrs[:first_name] = first_name if first_name.present? && user.first_name != first_name - update_attrs[:last_name] = last_name if last_name.present? && user.last_name != last_name + if user.first_name.blank? && first_name.present? + update_attrs[:first_name] = first_name + end + if user.last_name.blank? && last_name.present? + update_attrs[:last_name] = last_name + end user.update(update_attrs) if update_attrs.any?