Class: ApiGuard::AuthenticationController

Inherits:
ApplicationController show all
Defined in:
app/controllers/api_guard/authentication_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_resource

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
# File 'app/controllers/api_guard/authentication_controller.rb', line 8

def create
  if resource.authenticate(params[:password])
    create_token_and_set_header(resource, resource_name)
    render_success(message: I18n.t('api_guard.authentication.signed_in'))
  else
    render_error(422, message: I18n.t('api_guard.authentication.invalid_login_credentials'))
  end
end

#destroyObject



17
18
19
20
# File 'app/controllers/api_guard/authentication_controller.rb', line 17

def destroy
  blacklist_token
  render_success(message: I18n.t('api_guard.authentication.signed_out'))
end