diff options
author | Marin Jankovski <maxlazio@gmail.com> | 2014-12-29 09:30:55 +0100 |
---|---|---|
committer | Marin Jankovski <maxlazio@gmail.com> | 2014-12-29 09:30:55 +0100 |
commit | 42fb42aed4cc30d101e81fa5934d9f1b9521dfce (patch) | |
tree | 2efa529fe83f7d06d815bd153ae1ea9f8e1f4b7a /app/controllers | |
parent | 1c089a8561556377dccbf661a3016cac2329c713 (diff) | |
parent | 6cf501004b54c1b311ea7c6c364cfb4a88c1060b (diff) | |
download | gitlab-ce-42fb42aed4cc30d101e81fa5934d9f1b9521dfce.tar.gz |
Merge branch 'master' into developer_can_push_to_protected_branches_option
Conflicts:
db/schema.rb
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/application_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/oauth/applications_controller.rb | 41 | ||||
-rw-r--r-- | app/controllers/oauth/authorizations_controller.rb | 57 | ||||
-rw-r--r-- | app/controllers/oauth/authorized_applications_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/profiles_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/projects/services_controller.rb | 2 |
6 files changed, 112 insertions, 5 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 41ad5f98ace..4b8cae469e3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -257,10 +257,6 @@ class ApplicationController < ActionController::Base # or improve current implementation to filter only issues you # created or assigned or mentioned #@filter_params[:authorized_only] = true - - unless @filter_params[:assignee_id] - @filter_params[:assignee_id] = current_user.id - end end @filter_params diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb new file mode 100644 index 00000000000..3407490e498 --- /dev/null +++ b/app/controllers/oauth/applications_controller.rb @@ -0,0 +1,41 @@ +class Oauth::ApplicationsController < Doorkeeper::ApplicationsController + before_filter :authenticate_user! + layout "profile" + + def index + head :forbidden and return + end + + def create + @application = Doorkeeper::Application.new(application_params) + + if Doorkeeper.configuration.confirm_application_owner? + @application.owner = current_user + end + + if @application.save + flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create]) + redirect_to oauth_application_url(@application) + else + render :new + end + end + + def destroy + if @application.destroy + flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :destroy]) + end + + redirect_to applications_profile_url + end + + private + + def set_application + @application = current_user.oauth_applications.find(params[:id]) + end + + rescue_from ActiveRecord::RecordNotFound do |exception| + render "errors/not_found", layout: "errors", status: 404 + end +end diff --git a/app/controllers/oauth/authorizations_controller.rb b/app/controllers/oauth/authorizations_controller.rb new file mode 100644 index 00000000000..a57b4a60c24 --- /dev/null +++ b/app/controllers/oauth/authorizations_controller.rb @@ -0,0 +1,57 @@ +class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController + before_filter :authenticate_resource_owner! + layout "profile" + + def new + if pre_auth.authorizable? + if skip_authorization? || matching_token? + auth = authorization.authorize + redirect_to auth.redirect_uri + else + render "doorkeeper/authorizations/new" + end + else + render "doorkeeper/authorizations/error" + end + end + + # TODO: Handle raise invalid authorization + def create + redirect_or_render authorization.authorize + end + + def destroy + redirect_or_render authorization.deny + end + + private + + def matching_token? + Doorkeeper::AccessToken.matching_token_for(pre_auth.client, + current_resource_owner.id, + pre_auth.scopes) + end + + def redirect_or_render(auth) + if auth.redirectable? + redirect_to auth.redirect_uri + else + render json: auth.body, status: auth.status + end + end + + def pre_auth + @pre_auth ||= + Doorkeeper::OAuth::PreAuthorization.new(Doorkeeper.configuration, + server.client_via_uid, + params) + end + + def authorization + @authorization ||= strategy.request + end + + def strategy + @strategy ||= server.authorization_request(pre_auth.response_type) + end +end diff --git a/app/controllers/oauth/authorized_applications_controller.rb b/app/controllers/oauth/authorized_applications_controller.rb new file mode 100644 index 00000000000..0b27ce7da72 --- /dev/null +++ b/app/controllers/oauth/authorized_applications_controller.rb @@ -0,0 +1,8 @@ +class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicationsController + layout "profile" + + def destroy + Doorkeeper::AccessToken.revoke_all_for(params[:id], current_resource_owner) + redirect_to applications_profile_url, notice: I18n.t(:notice, scope: [:doorkeeper, :flash, :authorized_applications, :destroy]) + end +end diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index e877f9b9049..c0b7e2223a2 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -13,6 +13,11 @@ class ProfilesController < ApplicationController def design end + def applications + @applications = current_user.oauth_applications + @authorized_tokens = current_user.oauth_authorized_tokens + end + def update user_params.except!(:email) if @user.ldap_user? diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb index c50a1f1e75b..ef4d2609147 100644 --- a/app/controllers/projects/services_controller.rb +++ b/app/controllers/projects/services_controller.rb @@ -42,7 +42,7 @@ class Projects::ServicesController < Projects::ApplicationController :title, :token, :type, :active, :api_key, :subdomain, :room, :recipients, :project_url, :webhook, :user_key, :device, :priority, :sound, :bamboo_url, :username, :password, - :build_key, :server + :build_key, :server, :teamcity_url, :build_type ) end end |