Class: Lab::UsersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/lab/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

create a LIMS User that will be responsible for sending lab results



8
9
10
11
12
# File 'app/controllers/lab/users_controller.rb', line 8

def create
  user_params = params.permit(:username, :password)
  service.create_lims_user(username: user_params['username'], password: user_params['password'])
  render json: { message: 'User successfully created' }, status: 200
end

#loginObject

authenticate the lims user



15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/lab/users_controller.rb', line 15

def 
  user_params = params.permit(:username, :password)
  result = service.authenticate_user(username: user_params['username'], password: user_params['password'],
                                     user_agent: request.user_agent, request_ip: request.remote_ip)
  if result.present?
    render json: result, status: 200
  else
    render json: { message: 'Invalid Credentials Provided' }, status: 401
  end
end