2021-09-30 23:02:18 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Users
|
|
|
|
class UnsubscribesController < ApplicationController
|
|
|
|
skip_before_action :authenticate_user!
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
feature_category :user_profile
|
2021-09-30 23:02:18 +05:30
|
|
|
|
|
|
|
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
|