Class: Securial::UsersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/securial/users_controller.rb

Overview

UsersController

Controller for managing users in the Securial authentication system.

This controller provides administrative CRUD operations for user management, including:

- Listing all users in the system
- Creating new user accounts
- Viewing user details
- Updating user information
- Deleting user accounts

All operations require admin authentication and are typically used for administrative user management rather than self-service account management.

Routes typically mounted at Securial/admins/users/* in the host application.

Instance Method Summary collapse

Methods inherited from ApplicationController

#render_400, #render_404

Instance Method Details

#createvoid

This method returns an undefined value.

Creates a new user in the system.

Adds a new user with the provided attributes.

Parameters:

  • params[:securial_user] (Hash)

    User attributes including email_address, username, etc.



46
47
48
49
50
51
52
53
54
# File 'app/controllers/securial/users_controller.rb', line 46

def create
  @securial_user = User.new(securial_user_params)

  if @securial_user.save
    render :show, status: :created, location: @securial_user
  else
    render json: @securial_user.errors, status: :unprocessable_entity
  end
end

#destroyvoid

This method returns an undefined value.

Deletes an existing user.

Permanently removes a user from the system.

Parameters:

  • params[:id] (Integer)

    The ID of the user to delete



77
78
79
80
# File 'app/controllers/securial/users_controller.rb', line 77

def destroy
  @securial_user.destroy
  head :no_content
end

#indexvoid

This method returns an undefined value.

Lists all users in the system.

Retrieves all users for administrative display and management.



27
28
29
# File 'app/controllers/securial/users_controller.rb', line 27

def index
  @securial_users = User.all
end

#securial_user_paramsActionController::Parameters (private)

Permits and extracts user parameters from the request.

Returns:

  • (ActionController::Parameters)

    Permitted user parameters



95
96
97
98
99
100
101
102
103
104
105
106
# File 'app/controllers/securial/users_controller.rb', line 95

def securial_user_params
  params.expect(securial_user: [
                  :email_address,
                  :username,
                  :first_name,
                  :last_name,
                  :phone,
                  :bio,
                  :password,
                  :password_confirmation,
    ])
end

#set_securial_uservoid (private)

This method returns an undefined value.

Finds and sets a specific user for show, update and destroy actions.



88
89
90
# File 'app/controllers/securial/users_controller.rb', line 88

def set_securial_user
  @securial_user = User.find(params[:id])
end

#showvoid

This method returns an undefined value.

Shows details for a specific user.

Retrieves and displays information for a single user.

Parameters:

  • params[:id] (Integer)

    The ID of the user to display



37
38
# File 'app/controllers/securial/users_controller.rb', line 37

def show
end

#updatevoid

This method returns an undefined value.

Updates an existing user.

Modifies the attributes of an existing user.

Parameters:

  • params[:id] (Integer)

    The ID of the user to update

  • params[:securial_user] (Hash)

    Updated user attributes



63
64
65
66
67
68
69
# File 'app/controllers/securial/users_controller.rb', line 63

def update
  if @securial_user.update(securial_user_params)
    render :show, status: :ok, location: @securial_user
  else
    render json: @securial_user.errors, status: :unprocessable_entity
  end
end