FIX: redirect to original URL after social login

This commit is contained in:
Régis Hanol 2018-01-26 18:52:27 +01:00
parent 3d595a52ca
commit e2d82b882e
3 changed files with 9 additions and 4 deletions

View File

@ -217,7 +217,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
// Reload the page if we're authenticated
if (options.authenticated) {
const destinationUrl = $.cookie('destination_url');
const destinationUrl = $.cookie('destination_url') || options.destination_url;
if (destinationUrl) {
// redirect client to the original URL
$.cookie('destination_url', null);

View File

@ -41,6 +41,7 @@ class Users::OmniauthCallbacksController < ApplicationController
@auth_result = authenticator.after_authenticate(auth)
origin = request.env['omniauth.origin']
if cookies[:destination_url].present?
origin = cookies[:destination_url]
cookies.delete(:destination_url)
@ -53,8 +54,10 @@ class Users::OmniauthCallbacksController < ApplicationController
end
end
unless @origin.present?
if @origin.blank?
@origin = Discourse.base_uri("/")
else
@auth_result.destination_url = origin
end
if @auth_result.failed?

View File

@ -4,7 +4,7 @@ class Auth::Result
:awaiting_approval, :authenticated, :authenticator_name,
:requires_invite, :not_allowed_from_ip_address,
:admin_not_allowed_from_ip_address, :omit_username,
:skip_email_validation
:skip_email_validation, :destination_url
attr_accessor(
:failed,
@ -42,13 +42,15 @@ class Auth::Result
date: I18n.l(user.suspended_till, format: :date_only), reason: user.suspend_reason)
}
else
{
result = {
authenticated: !!authenticated,
awaiting_activation: !!awaiting_activation,
awaiting_approval: !!awaiting_approval,
not_allowed_from_ip_address: !!not_allowed_from_ip_address,
admin_not_allowed_from_ip_address: !!admin_not_allowed_from_ip_address
}
result[:destination_url] = destination_url if authenticated && destination_url.present?
result
end
else
result = { email: email,