Remove dead code
This commit is contained in:
committed by
Mike Dalessio
parent
db172bae4e
commit
71a332bb08
@@ -2,8 +2,6 @@ module Authentication
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
prepend_before_action :clear_old_scoped_session_cookies
|
||||
|
||||
before_action :require_account # Checking and setting account must happen first
|
||||
before_action :require_authentication
|
||||
helper_method :authenticated?
|
||||
@@ -20,9 +18,9 @@ module Authentication
|
||||
end
|
||||
|
||||
def allow_unauthenticated_access(**options)
|
||||
@unauthenticated_access_allowed = true
|
||||
skip_before_action :require_authentication, **options
|
||||
before_action :resume_session, **options
|
||||
allow_unauthorized_access **options
|
||||
end
|
||||
|
||||
def disallow_account_scope(**options)
|
||||
@@ -54,13 +52,6 @@ module Authentication
|
||||
end
|
||||
end
|
||||
|
||||
# FIXME: Remove before launch
|
||||
def clear_old_scoped_session_cookies
|
||||
if request.script_name.present? && cookies.signed[:session_token].present? && !find_session_by_cookie
|
||||
cookies.signed[:session_token] = { value: "invalid-session-token", path: request.script_name, expires: 1.hour.ago }
|
||||
end
|
||||
end
|
||||
|
||||
def find_session_by_cookie
|
||||
Session.find_signed(cookies.signed[:session_token])
|
||||
end
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
class Memberships::UnlinkController < ApplicationController
|
||||
disallow_account_scope
|
||||
before_action :set_membership
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def create
|
||||
@membership.destroy
|
||||
redirect_to session_menu_path
|
||||
end
|
||||
|
||||
private
|
||||
def set_membership
|
||||
@membership = Current.identity.memberships.find_signed!(params[:membership_id], purpose: :unlinking)
|
||||
end
|
||||
end
|
||||
@@ -1,24 +0,0 @@
|
||||
<% @page_title = "Leaving #{@membership.account_name}" %>
|
||||
|
||||
<div class="panel panel--centered flex flex-column gap-half">
|
||||
<header>
|
||||
<h1 class="txt-x-large font-weight-black margin-none">
|
||||
<%= @page_title %>
|
||||
</h1>
|
||||
<p class="margin-none-block-start">You no longer have access to this account.</p>
|
||||
</header>
|
||||
|
||||
<%= form_with \
|
||||
url: unlink_membership_path(membership_id: params[:membership_id]),
|
||||
class: "flex flex-column gap txt-medium",
|
||||
data: { controller: "form auto-submit" } do |form| %>
|
||||
<button type="submit" id="log_in" class="btn btn--link center" data-form-target="submit">
|
||||
<span>Leave</span>
|
||||
<%= icon_tag "arrow-right" %>
|
||||
</button>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<% content_for :footer do %>
|
||||
<%= render "sessions/footer" %>
|
||||
<% end %>
|
||||
@@ -148,8 +148,6 @@ Rails.application.routes.draw do
|
||||
resource :landing
|
||||
|
||||
scope module: :memberships, path: "memberships/:membership_id" do
|
||||
resource :unlink, only: %i[ show create ], controller: :unlink, as: :unlink_membership
|
||||
|
||||
resources :email_addresses, param: :token do
|
||||
resource :confirmation, module: :email_addresses
|
||||
end
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
require "test_helper"
|
||||
|
||||
class Memberships::UnlinkControllerTest < ActionDispatch::IntegrationTest
|
||||
test "show" do
|
||||
untenanted do
|
||||
sign_in_as :kevin
|
||||
|
||||
membership = memberships(:kevin_in_37signals)
|
||||
signed_id = membership.signed_id(purpose: :unlinking)
|
||||
|
||||
get unlink_membership_path(membership_id: signed_id)
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
test "create" do
|
||||
untenanted do
|
||||
sign_in_as :kevin
|
||||
|
||||
membership = memberships(:kevin_in_37signals)
|
||||
signed_id = membership.signed_id(purpose: :unlinking)
|
||||
|
||||
assert_difference -> { Membership.count }, -1 do
|
||||
post unlink_membership_path(membership_id: signed_id)
|
||||
end
|
||||
|
||||
assert_redirected_to session_menu_path
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user