Commit 6fec8afc authored by Eugen Rochko's avatar Eugen Rochko

Bind oauth applications to users

parent 25d7c1b6
# 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:
......@@ -247,6 +247,12 @@
input[type=file] {
display: block;
.hint {
display: block;
margin-top: 5px;
color: lighten(#282c37, 25%);
// 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:
class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
before_filter :authenticate_user!
def index
@applications = current_user.oauth_applications
def create
@application =
@application.owner = current_user
redirect_to oauth_application_url(@application)
render :new
module Oauth::ApplicationsHelper
......@@ -5,4 +5,6 @@ class User < ActiveRecord::Base
accepts_nested_attributes_for :account
validates :account, presence: true
has_many :oauth_applications, class_name: 'Doorkeeper::Application', as: :owner
......@@ -45,7 +45,7 @@ Doorkeeper.configure do
# Optional parameter :confirmation => true (default false) if you want to enforce ownership of
# a registered application
# Note: you must also run the rails g doorkeeper:application_owner generator to provide the necessary support
# enable_application_owner :confirmation => false
enable_application_owner :confirmation => true
# Define access token scopes for your provider
# For more information go to
Rails.application.routes.draw do
use_doorkeeper do
controllers applications: 'oauth/applications'
get '.well-known/host-meta', to: 'xrd#host_meta', as: :host_meta
get '.well-known/webfinger', to: 'xrd#webfinger', as: :webfinger
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]
\ No newline at end of file
......@@ -11,7 +11,7 @@
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160312193225) do
ActiveRecord::Schema.define(version: 20160314164231) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -107,8 +107,11 @@ ActiveRecord::Schema.define(version: 20160312193225) do
t.string "scopes", default: "", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.integer "owner_id"
t.string "owner_type"
add_index "oauth_applications", ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type", using: :btree
add_index "oauth_applications", ["uid"], name: "index_oauth_applications_on_uid", unique: true, using: :btree
create_table "statuses", force: :cascade do |t|
require 'rails_helper'
RSpec.describe Oauth::ApplicationsController, type: :controller do
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__}"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment