diff --git a/app/controllers/api/v2/tokens_controller.rb b/app/controllers/api/v2/tokens_controller.rb index 92a2cfbc..536d4bf6 100644 --- a/app/controllers/api/v2/tokens_controller.rb +++ b/app/controllers/api/v2/tokens_controller.rb @@ -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 diff --git a/app/controllers/tokens_controller.rb b/app/controllers/tokens_controller.rb new file mode 100644 index 00000000..b434d122 --- /dev/null +++ b/app/controllers/tokens_controller.rb @@ -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 diff --git a/app/views/tokens/new.html.erb b/app/views/tokens/new.html.erb new file mode 100644 index 00000000..e655010d --- /dev/null +++ b/app/views/tokens/new.html.erb @@ -0,0 +1,5 @@ +<%= form_for @token, url: '/api/v2/tokens', method: :post do |form| %> +

Request new API Token

+ <%= form.text_field :description, placeholder: "Token description..." %> + <%= form.submit %> +<% end %> diff --git a/config/routes.rb b/config/routes.rb index 1eae4b96..f2850c81 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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',