/tokens/new form
This commit is contained in:
parent
ad7830805f
commit
f9f1598529
4 changed files with 17 additions and 1 deletions
|
@ -22,7 +22,7 @@ module Api
|
|||
private
|
||||
|
||||
def current_user
|
||||
token_user || doorkeeper_user || super
|
||||
token_user || doorkeeper_user || method(:current_user).super_method.super_method.call
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
9
app/controllers/tokens_controller.rb
Normal file
9
app/controllers/tokens_controller.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
class TokensController < ApplicationController
|
||||
before_action :require_user, only: [:new]
|
||||
|
||||
def new
|
||||
@token = Token.new(user: current_user)
|
||||
render :new, layout: false
|
||||
end
|
||||
end
|
5
app/views/tokens/new.html.erb
Normal file
5
app/views/tokens/new.html.erb
Normal file
|
@ -0,0 +1,5 @@
|
|||
<%= form_for @token, url: '/api/v2/tokens', method: :post do |form| %>
|
||||
<h4>Request new API Token</h4>
|
||||
<%= form.text_field :description, placeholder: "Token description..." %>
|
||||
<%= form.submit %>
|
||||
<% end %>
|
|
@ -89,6 +89,8 @@ Metamaps::Application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
resources :tokens, only: [:new]
|
||||
|
||||
devise_for :users, skip: :sessions, controllers: {
|
||||
registrations: 'users/registrations',
|
||||
passwords: 'users/passwords',
|
||||
|
|
Loading…
Add table
Reference in a new issue