2024-06-30 06:31:21 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
class Settings::UsersController < ApplicationController
|
2025-01-15 15:52:59 -05:00
|
|
|
before_action :authenticate_self_hosted!
|
2025-03-16 08:36:06 -04:00
|
|
|
before_action :authenticate_admin!
|
2024-06-30 06:31:21 -04:00
|
|
|
|
2024-11-08 11:56:14 -05:00
|
|
|
def index
|
|
|
|
|
@users = User.order(created_at: :desc)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def edit
|
|
|
|
|
@user = User.find(params[:id])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def update
|
|
|
|
|
@user = User.find(params[:id])
|
|
|
|
|
|
|
|
|
|
if @user.update(user_params)
|
|
|
|
|
redirect_to settings_users_url, notice: 'User was successfully updated.'
|
|
|
|
|
else
|
|
|
|
|
redirect_to settings_users_url, notice: 'User could not be updated.', status: :unprocessable_entity
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2024-06-30 06:31:21 -04:00
|
|
|
def create
|
|
|
|
|
@user = User.new(
|
|
|
|
|
email: user_params[:email],
|
2024-11-12 08:56:48 -05:00
|
|
|
password: user_params[:password],
|
|
|
|
|
password_confirmation: user_params[:password]
|
2024-06-30 06:31:21 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if @user.save
|
2024-11-12 08:56:48 -05:00
|
|
|
redirect_to settings_users_url, notice: 'User was successfully created'
|
2024-06-30 06:31:21 -04:00
|
|
|
else
|
2024-11-08 11:56:14 -05:00
|
|
|
redirect_to settings_users_url, notice: 'User could not be created.', status: :unprocessable_entity
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
|
@user = User.find(params[:id])
|
|
|
|
|
|
|
|
|
|
if @user.destroy
|
|
|
|
|
redirect_to settings_url, notice: 'User was successfully deleted.'
|
|
|
|
|
else
|
|
|
|
|
redirect_to settings_url, notice: 'User could not be deleted.', status: :unprocessable_entity
|
2024-06-30 06:31:21 -04:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-06-25 15:14:33 -04:00
|
|
|
def export
|
|
|
|
|
current_user.export_data
|
|
|
|
|
|
|
|
|
|
redirect_to exports_path, notice: 'Your data is being exported. You will receive a notification when it is ready.'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def import
|
2025-06-26 13:24:40 -04:00
|
|
|
|
|
|
|
|
end
|
2025-06-25 15:14:33 -04:00
|
|
|
|
2024-06-30 06:31:21 -04:00
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def user_params
|
2024-11-12 08:56:48 -05:00
|
|
|
params.require(:user).permit(:email, :password)
|
2024-06-30 06:31:21 -04:00
|
|
|
end
|
|
|
|
|
end
|