summaryrefslogtreecommitdiff
path: root/app/controllers/users/unsubscribes_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/users/unsubscribes_controller.rb')
-rw-r--r--app/controllers/users/unsubscribes_controller.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/app/controllers/users/unsubscribes_controller.rb b/app/controllers/users/unsubscribes_controller.rb
new file mode 100644
index 00000000000..9ac07083cd5
--- /dev/null
+++ b/app/controllers/users/unsubscribes_controller.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+module Users
+ class UnsubscribesController < ApplicationController
+ skip_before_action :authenticate_user!
+
+ feature_category :users
+
+ def show
+ @user = get_user
+ end
+
+ def create
+ @user = get_user
+
+ if @user
+ @user.admin_unsubscribe!
+ Notify.send_unsubscribed_notification(@user.id).deliver_later
+ end
+
+ redirect_to new_user_session_path, notice: 'You have been unsubscribed'
+ end
+
+ protected
+
+ # rubocop: disable CodeReuse/ActiveRecord
+ def get_user
+ @email = Base64.urlsafe_decode64(params[:email])
+ User.find_by(email: @email)
+ end
+ # rubocop: enable CodeReuse/ActiveRecord
+ end
+end