Sha256: b69a76d41a51ad09449849e69f5ce6b04700cd7b63a79e10b557af5d1a57d15f
Contents?: true
Size: 602 Bytes
Versions: 2
Compression:
Stored size: 602 Bytes
Contents
# frozen_string_literal: true module Tokenable class TokensController < ::ActionController::API include Authable rescue_from 'Tokenable::Unauthorized' do render json: { error: 'Login failed, please try again.' }, status: 401 end def create user = Tokenable::Config.user_class.from_tokenable_params(params) raise Tokenable::Unauthorized, 'No user returned by strategy' unless user response = { data: { token: token_from_user(user), user_id: user.id, }, } render json: response, status: 201 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tokenable-ruby-0.3.0 | lib/tokenable/controllers/tokens_controller.rb |
tokenable-ruby-0.2.0 | lib/tokenable/controllers/tokens_controller.rb |