Class: Lab::UsersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Lab::UsersController
- Defined in:
- app/controllers/lab/users_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
create a LIMS User that will be responsible for sending lab results.
-
#login ⇒ Object
authenticate the lims user.
Instance Method Details
#create ⇒ Object
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 |
#login ⇒ Object
authenticate the lims user
15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/lab/users_controller.rb', line 15 def login 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 |