mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 18:22:40 +08:00
FEATURE: improve email change workflow
- Show old and new email address during the process - Ensure correct user is logged on when attempting to make email changes - Support reloading a page during the email reset process without resubmit of form - Improve tests - Fixed issue where redirect back to site was not linking correctly in subfolder setups Internal refactor of single action into 4 distinct actions that are simpler to reason about. This also removes the step that logs on an account after you confirm an email change, since it is no longer needed which leaves us with safer internals. This left me no choice but to amend translations cause the old route was removed.
This commit is contained in:
@ -687,6 +687,25 @@ class ApplicationController < ActionController::Base
|
||||
request.original_url unless request.original_url =~ /uploads/
|
||||
end
|
||||
|
||||
def redirect_to_login
|
||||
dont_cache_page
|
||||
|
||||
if SiteSetting.enable_sso?
|
||||
# save original URL in a session so we can redirect after login
|
||||
session[:destination_url] = destination_url
|
||||
redirect_to path('/session/sso')
|
||||
elsif !SiteSetting.enable_local_logins && Discourse.enabled_authenticators.length == 1 && !cookies[:authentication_data]
|
||||
# Only one authentication provider, direct straight to it.
|
||||
# If authentication_data is present, then we are halfway though registration. Don't redirect offsite
|
||||
cookies[:destination_url] = destination_url
|
||||
redirect_to path("/auth/#{Discourse.enabled_authenticators.first.name}")
|
||||
else
|
||||
# save original URL in a cookie (javascript redirects after login in this case)
|
||||
cookies[:destination_url] = destination_url
|
||||
redirect_to path("/login")
|
||||
end
|
||||
end
|
||||
|
||||
def redirect_to_login_if_required
|
||||
return if request.format.json? && is_api?
|
||||
|
||||
@ -715,24 +734,8 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
if !current_user && SiteSetting.login_required?
|
||||
flash.keep
|
||||
dont_cache_page
|
||||
|
||||
if SiteSetting.enable_sso?
|
||||
# save original URL in a session so we can redirect after login
|
||||
session[:destination_url] = destination_url
|
||||
redirect_to path('/session/sso')
|
||||
return
|
||||
elsif !SiteSetting.enable_local_logins && Discourse.enabled_authenticators.length == 1 && !cookies[:authentication_data]
|
||||
# Only one authentication provider, direct straight to it.
|
||||
# If authentication_data is present, then we are halfway though registration. Don't redirect offsite
|
||||
cookies[:destination_url] = destination_url
|
||||
redirect_to path("/auth/#{Discourse.enabled_authenticators.first.name}")
|
||||
else
|
||||
# save original URL in a cookie (javascript redirects after login in this case)
|
||||
cookies[:destination_url] = destination_url
|
||||
redirect_to path("/login")
|
||||
return
|
||||
end
|
||||
redirect_to_login
|
||||
return
|
||||
end
|
||||
|
||||
check_totp = current_user &&
|
||||
|
Reference in New Issue
Block a user