Class: Proctoring::Api::V1::AuthenticationController
- Inherits:
-
Proctoring::ApplicationController
- Object
- ActionController::Base
- Proctoring::ApplicationController
- Proctoring::Api::V1::AuthenticationController
- Includes:
- HundredMsServiceHelper, TokensHelper
- Defined in:
- app/controllers/proctoring/api/v1/authentication_controller.rb
Instance Method Summary collapse
Methods included from HundredMsServiceHelper
#add_room_to_the_cache, #generate_room, #room_already_exists?, #room_exists_with_space?
Methods included from TokensHelper
encode_authentication_token, #generate_authentication_token, #generate_management_token
Methods inherited from Proctoring::ApplicationController
#authenticate_api_token, #authenticate_app_token
Instance Method Details
#create ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/proctoring/api/v1/authentication_controller.rb', line 9 def create event_id = params[:event_id] user_id = params[:user_id] role = params[:role] max_people_allowed = params[:max_people_allowed] room_id = room_already_exists?(event_id, user_id) room_id ||= room_exists_with_space?(event_id, user_id, role, max_people_allowed) if room_id.blank? room_id = generate_room({ event_id: event_id })['id'] add_room_to_the_cache(room_id, user_id, role, event_id) end authentication_params = { user_id: user_id, role: role, room_id: room_id } authentication_token = generate_authentication_token(authentication_params) render json: { success: true, authentication_token: authentication_token } rescue StandardError => e render json: { success: false, error: e. }, status: :internal_server_error end |