Class: Admin::TokensController

Inherits:
ApplicationController show all
Includes:
Koi::Controller::JsonWebToken
Defined in:
app/controllers/admin/tokens_controller.rb

Constant Summary

Constants included from Koi::Controller::JsonWebToken

Koi::Controller::JsonWebToken::SECRET_KEY

Instance Method Summary collapse

Methods included from Koi::Controller::JsonWebToken

#decode_token, #encode_token

Instance Method Details

#createObject



15
16
17
18
19
# File 'app/controllers/admin/tokens_controller.rb', line 15

def create
  token = encode_token(admin_id: @admin.id, exp: 30.minutes.from_now.to_i, iat: Time.current.to_i)

  render locals: { token: }
end

#showObject



11
12
13
# File 'app/controllers/admin/tokens_controller.rb', line 11

def show
  render locals: { admin: @admin, token: params[:token] }, layout: "koi/login"
end

#updateObject



21
22
23
24
25
# File 'app/controllers/admin/tokens_controller.rb', line 21

def update
  (@admin)

  redirect_to admin_admin_user_path(@admin), status: :see_other, notice: t("koi.auth.token_consumed")
end