mirror of https://github.com/mastodon/mastodon
Bind oauth applications to users
parent
25d7c1b6ea
commit
6fec8afc3f
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the oauth::applications controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
@ -0,0 +1,18 @@
|
||||
class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
|
||||
before_filter :authenticate_user!
|
||||
|
||||
def index
|
||||
@applications = current_user.oauth_applications
|
||||
end
|
||||
|
||||
def create
|
||||
@application = Doorkeeper::Application.new(application_params)
|
||||
@application.owner = current_user
|
||||
|
||||
if @application.save
|
||||
redirect_to oauth_application_url(@application)
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,2 @@
|
||||
module Oauth::ApplicationsHelper
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
class AddOwnerToApplication < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :oauth_applications, :owner_id, :integer, null: true
|
||||
add_column :oauth_applications, :owner_type, :string, null: true
|
||||
add_index :oauth_applications, [:owner_id, :owner_type]
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Oauth::ApplicationsController, type: :controller do
|
||||
|
||||
end
|
@ -0,0 +1,15 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the Oauth::ApplicationsHelper. For example:
|
||||
#
|
||||
# describe Oauth::ApplicationsHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe Oauth::ApplicationsHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue