mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Ensure email validation link returns to /register paths properly
This commit is contained in:
committed by
Maikel Linke
parent
d7a3c50bd5
commit
e8bc87e62b
@@ -20,8 +20,8 @@ Darkswarm.controller "LoginCtrl", ($scope, $timeout, $location, $http, $window,
|
||||
$scope.errors = t('devise.confirmations.failed_to_send')
|
||||
|
||||
$timeout ->
|
||||
if angular.isDefined($location.search()['confirmation'])
|
||||
if $location.search()['confirmation'] == 'confirmed'
|
||||
if angular.isDefined($location.search()['validation'])
|
||||
if $location.search()['validation'] == 'confirmed'
|
||||
$scope.messages = t('devise.confirmations.confirmed')
|
||||
if $location.search()['confirmation'] == 'not_confirmed'
|
||||
if $location.search()['validation'] == 'not_confirmed'
|
||||
$scope.errors = t('devise.confirmations.not_confirmed')
|
||||
|
||||
@@ -7,7 +7,10 @@ Darkswarm.factory "AuthenticationService", (Navigation, $modal, $location, Redir
|
||||
if $location.path() in ["/login", "/signup", "/forgot"] && location.pathname isnt '/register/auth'
|
||||
@open $location.path()
|
||||
else if location.pathname is '/register/auth'
|
||||
@open '/signup', 'registration_authentication.html'
|
||||
if angular.isDefined($location.search()['validation'])
|
||||
@open '/login', 'registration_authentication.html'
|
||||
else
|
||||
@open '/signup', 'registration_authentication.html'
|
||||
|
||||
open: (path = false, template = 'authentication.html') =>
|
||||
@modalInstance = $modal.open
|
||||
|
||||
@@ -38,7 +38,8 @@ class UserConfirmationsController < DeviseController
|
||||
'not_confirmed'
|
||||
end
|
||||
|
||||
url = session[:confirmation_return_url] || login_path
|
||||
url + "?confirmation=#{result}"
|
||||
path = (session[:confirmation_return_url] || login_path).to_s
|
||||
path += path.include?('?') ? '&' : '?'
|
||||
path + "validation=#{result}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,14 +20,14 @@ describe UserConfirmationsController, type: :controller do
|
||||
end
|
||||
|
||||
it "redirects the user to login" do
|
||||
expect(response).to redirect_to login_path(confirmation: 'not_confirmed')
|
||||
expect(response).to redirect_to login_path(validation: 'not_confirmed')
|
||||
end
|
||||
end
|
||||
|
||||
context "that has not been confirmed" do
|
||||
it "redirects the user to login" do
|
||||
spree_get :show, confirmation_token: unconfirmed_user.confirmation_token
|
||||
expect(response).to redirect_to login_path(confirmation: 'confirmed')
|
||||
expect(response).to redirect_to login_path(validation: 'confirmed')
|
||||
end
|
||||
|
||||
it "confirms the user" do
|
||||
@@ -38,7 +38,13 @@ describe UserConfirmationsController, type: :controller do
|
||||
it "redirects to previous url" do
|
||||
session[:confirmation_return_url] = producers_path + '#/login'
|
||||
spree_get :show, confirmation_token: unconfirmed_user.confirmation_token
|
||||
expect(response).to redirect_to producers_path + '#/login?confirmation=confirmed'
|
||||
expect(response).to redirect_to producers_path + '#/login?validation=confirmed'
|
||||
end
|
||||
|
||||
it "redirects to previous url on /register path" do
|
||||
session[:confirmation_return_url] = registration_path + '#/signup?after_login=%2Fregister'
|
||||
spree_get :show, confirmation_token: unconfirmed_user.confirmation_token
|
||||
expect(response).to redirect_to registration_path + '#/signup?after_login=%2Fregister&validation=confirmed'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -124,7 +124,7 @@ feature "Authentication", js: true, retry: 3 do
|
||||
|
||||
describe "after following email confirmation link" do
|
||||
scenario "shows confirmed message in modal" do
|
||||
visit '/#/login?confirmation=confirmed'
|
||||
visit '/#/login?validation=confirmed'
|
||||
expect(page).to have_login_modal
|
||||
expect(page).to have_content I18n.t('devise.confirmations.confirmed')
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user