make unsubscribing work even if logged out
This commit is contained in:
parent
4629ebf8f9
commit
5698c3bad4
4 changed files with 24 additions and 2 deletions
|
@ -58,7 +58,8 @@ class NotificationsController < ApplicationController
|
||||||
# TODO will a logged out user be unsubscribed after logging in?
|
# TODO will a logged out user be unsubscribed after logging in?
|
||||||
# need to use devise stored_url or whatever
|
# need to use devise stored_url or whatever
|
||||||
if current_user.nil?
|
if current_user.nil?
|
||||||
return redirect_to sign_in_path, notice: 'Continue to unsubscribe from emails by logging in.'
|
flash[:notice] = 'Continue to unsubscribe from emails by logging in.'
|
||||||
|
return redirect_to "#{sign_in_path}?redirect_to=#{unsubscribe_notifications_path}"
|
||||||
end
|
end
|
||||||
|
|
||||||
if current_user.emails_allowed == false
|
if current_user.emails_allowed == false
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
class Users::SessionsController < Devise::SessionsController
|
class Users::SessionsController < Devise::SessionsController
|
||||||
|
after_action :store_location, only: [:new]
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def after_sign_in_path_for(resource)
|
def after_sign_in_path_for(resource)
|
||||||
|
@ -11,4 +13,12 @@ class Users::SessionsController < Devise::SessionsController
|
||||||
request.referer || root_path
|
request.referer || root_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def store_location
|
||||||
|
if params[:redirect_to]
|
||||||
|
store_location_for(User, params[:redirect_to])
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -64,9 +64,13 @@
|
||||||
<p id="toast" class="toast">
|
<p id="toast" class="toast">
|
||||||
<% if devise_error_messages? %>
|
<% if devise_error_messages? %>
|
||||||
<%= devise_error_messages! %>
|
<%= devise_error_messages! %>
|
||||||
<% elsif notice %>
|
<% end %>
|
||||||
|
<% if notice %>
|
||||||
<%= notice %>
|
<%= notice %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if alert %>
|
||||||
|
<%= alert %>
|
||||||
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
<div id="loading"></div>
|
<div id="loading"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -32,6 +32,13 @@ Run these tests to be reasonably sure that your code changes haven't broken anyt
|
||||||
- Add a number of synapses to one of your maps. Reload to see if they are still there.
|
- Add a number of synapses to one of your maps. Reload to see if they are still there.
|
||||||
- Rearrange one of your maps and save the layout. Reload to see if the layout is preserved.
|
- Rearrange one of your maps and save the layout. Reload to see if the layout is preserved.
|
||||||
|
|
||||||
|
### Unsubscribing from Notifications
|
||||||
|
|
||||||
|
- Log out
|
||||||
|
- Visit /notifications/unsubscribe. It should redirect you to the login page.
|
||||||
|
- Log in.
|
||||||
|
- It should redirect you to the user edit page, and you should be unsubscribed.
|
||||||
|
|
||||||
### Misc
|
### Misc
|
||||||
|
|
||||||
- Login as admin. Change metacode sets.
|
- Login as admin. Change metacode sets.
|
||||||
|
|
Loading…
Add table
Reference in a new issue