mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FIX: redirect users after signing up using SSO provider
This commit is contained in:
@ -44,8 +44,15 @@ class SessionController < ApplicationController
|
||||
|
||||
def sso_provider(payload = nil)
|
||||
payload ||= request.query_string
|
||||
|
||||
if SiteSetting.enable_sso_provider
|
||||
sso = SingleSignOn.parse(payload, SiteSetting.sso_secret)
|
||||
|
||||
if sso.return_sso_url.blank?
|
||||
render plain: "return_sso_url is blank, it must be provided", status: 400
|
||||
return
|
||||
end
|
||||
|
||||
if current_user
|
||||
sso.name = current_user.name
|
||||
sso.username = current_user.username
|
||||
@ -55,19 +62,17 @@ class SessionController < ApplicationController
|
||||
sso.moderator = current_user.moderator?
|
||||
sso.groups = current_user.groups.pluck(:name).join(",")
|
||||
|
||||
sso.avatar_url = Discourse.store.cdn_url UrlHelper.absolute(
|
||||
"#{Discourse.store.absolute_base_url}/#{Discourse.store.get_path_for_upload(current_user.uploaded_avatar)}"
|
||||
) unless current_user.uploaded_avatar.nil?
|
||||
sso.profile_background_url = UrlHelper.absolute upload_cdn_path(
|
||||
current_user.user_profile.profile_background
|
||||
) if current_user.user_profile.profile_background.present?
|
||||
sso.card_background_url = UrlHelper.absolute upload_cdn_path(
|
||||
current_user.user_profile.card_background
|
||||
) if current_user.user_profile.card_background.present?
|
||||
if current_user.uploaded_avatar.present?
|
||||
avatar_url = "#{Discourse.store.absolute_base_url}/#{Discourse.store.get_path_for_upload(current_user.uploaded_avatar)}"
|
||||
sso.avatar_url = UrlHelper.absolute Discourse.store.cdn_url(avatar_url)
|
||||
end
|
||||
|
||||
if sso.return_sso_url.blank?
|
||||
render plain: "return_sso_url is blank, it must be provided", status: 400
|
||||
return
|
||||
if current_user.user_profile.profile_background.present?
|
||||
sso.profile_background_url = UrlHelper.absolute upload_cdn_path(current_user.user_profile.profile_background)
|
||||
end
|
||||
|
||||
if current_user.user_profile.card_background.present?
|
||||
sso.card_background_url = UrlHelper.absolute upload_cdn_path(current_user.user_profile.card_background)
|
||||
end
|
||||
|
||||
if request.xhr?
|
||||
@ -76,7 +81,7 @@ class SessionController < ApplicationController
|
||||
redirect_to sso.to_url(sso.return_sso_url)
|
||||
end
|
||||
else
|
||||
session[:sso_payload] = request.query_string
|
||||
cookies[:sso_payload] = request.query_string
|
||||
redirect_to path('/login')
|
||||
end
|
||||
else
|
||||
@ -399,7 +404,7 @@ class SessionController < ApplicationController
|
||||
session.delete(ACTIVATE_USER_KEY)
|
||||
log_on_user(user)
|
||||
|
||||
if payload = session.delete(:sso_payload)
|
||||
if payload = cookies.delete(:sso_payload)
|
||||
sso_provider(payload)
|
||||
else
|
||||
render_serialized(user, UserSerializer)
|
||||
|
Reference in New Issue
Block a user