Sha256: 83bbb40ab7ea872f9c035329c8f953182ec03b07b2dd1724be965bc5de915248
Contents?: true
Size: 799 Bytes
Versions: 181
Compression:
Stored size: 799 Bytes
Contents
# frozen_string_literal: true module Motor class AuthTokensController < ApiBaseController GENERIC_TOKEN_TTL = 2.hours skip_authorization_check def create return render json: {} unless current_user if defined?(Devise::JWT) respond_with_devise_jwt elsif defined?(JWT) respond_with_generic_jwt else render json: {} end end private def respond_with_devise_jwt warden.set_user(current_user) render json: { token: request.env['warden-jwt_auth.token'] } end def respond_with_generic_jwt payload = { uid: current_user.id, exp: GENERIC_TOKEN_TTL.from_now.to_i } token = JWT.encode(payload, Rails.application.secrets.secret_key_base) render json: { token: token } end end end
Version data entries
181 entries across 181 versions & 5 rubygems