Class: Tramway::Api::V1::UserTokensController

Inherits:
ApplicationController show all
Defined in:
app/controllers/tramway/api/v1/user_tokens_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#render_error_with_text, #render_errors_for, #snake_case

Instance Method Details

#createObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/tramway/api/v1/user_tokens_controller.rb', line 4

def create
  if entity.present? && entity.authenticate(auth_params[:password])
    token = auth_token
    render json: {
      auth_token: token,
      user: {
        email: @entity.email,
        uuid: @entity.uuid
      }
    }, status: :created
  else
    unauthorized
  end
end