about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-14 17:49:13 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-03-14 17:49:13 +0100
commit6fec8afc3f91166930c8b4dfca441a5a70a24d5b (patch)
tree4cd02810b87de1dccf7b96630910921d76357921 /app
parent25d7c1b6eaf03ddaec892c82f7d93a128b79a872 (diff)
Bind oauth applications to users
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/oauth/applications.coffee3
-rw-r--r--app/assets/stylesheets/dashboard.scss6
-rw-r--r--app/assets/stylesheets/oauth/applications.scss3
-rw-r--r--app/controllers/oauth/applications_controller.rb18
-rw-r--r--app/helpers/oauth/applications_helper.rb2
-rw-r--r--app/models/user.rb2
6 files changed, 34 insertions, 0 deletions
diff --git a/app/assets/javascripts/oauth/applications.coffee b/app/assets/javascripts/oauth/applications.coffee
new file mode 100644
index 000000000..24f83d18b
--- /dev/null
+++ b/app/assets/javascripts/oauth/applications.coffee
@@ -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/
diff --git a/app/assets/stylesheets/dashboard.scss b/app/assets/stylesheets/dashboard.scss
index 166ce42c1..08a9415d1 100644
--- a/app/assets/stylesheets/dashboard.scss
+++ b/app/assets/stylesheets/dashboard.scss
@@ -247,6 +247,12 @@
     input[type=file] {
       display: block;
     }
+
+    .hint {
+      display: block;
+      margin-top: 5px;
+      color: lighten(#282c37, 25%);
+    }
   }
 }
 
diff --git a/app/assets/stylesheets/oauth/applications.scss b/app/assets/stylesheets/oauth/applications.scss
new file mode 100644
index 000000000..50933741e
--- /dev/null
+++ b/app/assets/stylesheets/oauth/applications.scss
@@ -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/
diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb
new file mode 100644
index 000000000..4614ef2f7
--- /dev/null
+++ b/app/controllers/oauth/applications_controller.rb
@@ -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
diff --git a/app/helpers/oauth/applications_helper.rb b/app/helpers/oauth/applications_helper.rb
new file mode 100644
index 000000000..2c1818055
--- /dev/null
+++ b/app/helpers/oauth/applications_helper.rb
@@ -0,0 +1,2 @@
+module Oauth::ApplicationsHelper
+end
diff --git a/app/models/user.rb b/app/models/user.rb
index 038ff21c6..b17eabcc4 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -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
 end