From bd8ff93c8c3bc918cf926a3108eaacbf2e3a093e Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Sun, 10 May 2015 20:04:02 +0200 Subject: Improve text on error pages. --- public/404.html | 7 ++++--- public/422.html | 12 ++++++------ public/500.html | 5 +++-- public/502.html | 3 ++- public/deploy.html | 12 +++++++++--- public/static.css | 10 ++++++++-- 6 files changed, 32 insertions(+), 17 deletions(-) diff --git a/public/404.html b/public/404.html index 867f193a98f..a0106bc760d 100644 --- a/public/404.html +++ b/public/404.html @@ -1,14 +1,15 @@ - The page you were looking for doesn't exist (404) + The page you're looking for could not be found (404)

404

-

The page you were looking for doesn't exist.

+

The page you're looking for could not be found.


-

You may have mistyped the address or the page may have moved.

+

Make sure the address is correct and that the page hasn't moved.

+

Please contact your GitLab administrator if you think this is a mistake.

diff --git a/public/422.html b/public/422.html index b6c37ac5386..cad385ac153 100644 --- a/public/422.html +++ b/public/422.html @@ -1,16 +1,16 @@ - The change you wanted was rejected (422) - + The change you requested was rejected (422) +

422

-
-

The change you wanted was rejected.

-

Maybe you tried to change something you didn't have access to.

-
+

The change you requested was rejected.

+
+

Make sure you have access to the thing you tried to change.

+

Please contact your GitLab administrator if you think this is a mistake.

diff --git a/public/500.html b/public/500.html index c84b9e90e4b..08c11bbd05a 100644 --- a/public/500.html +++ b/public/500.html @@ -1,13 +1,14 @@ - We're sorry, but something went wrong (500) + Something went wrong (500)

500

-

We're sorry, but something went wrong.

+

Whoops, something went wrong on our end.


+

Try refreshing the page, or going back and attempting the action again.

Please contact your GitLab administrator if this problem persists.

diff --git a/public/502.html b/public/502.html index d171eccc927..9480a928439 100644 --- a/public/502.html +++ b/public/502.html @@ -6,8 +6,9 @@

502

-

GitLab is not responding.

+

Whoops, GitLab is taking too much time to respond.


+

Try refreshing the page, or going back and attempting the action again.

Please contact your GitLab administrator if this problem persists.

diff --git a/public/deploy.html b/public/deploy.html index e41ed76573d..1a41b772f3c 100644 --- a/public/deploy.html +++ b/public/deploy.html @@ -1,11 +1,17 @@ - Deploy in progress. Please try again in a few minutes + Deploy in progress + -

Deploy in progress

-

Please try again in a few minutes or contact your administrator.

+

+
+ Deploy in progress +

+

Please try again in a few minutes.

+
+

Please contact your GitLab administrator if this problem persists.

diff --git a/public/static.css b/public/static.css index c6f92ac01d9..0a2b6060d48 100644 --- a/public/static.css +++ b/public/static.css @@ -2,18 +2,24 @@ body { color: #666; text-align: center; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; - margin:0; + margin: 0; width: 800px; margin: auto; font-size: 14px; } + h1 { font-size: 56px; line-height: 100px; font-weight: normal; color: #456; } -h2 { font-size: 24px; color: #666; line-height: 1.5em; } + +h2 { + font-size: 24px; + color: #666; + line-height: 1.5em; +} h3 { color: #456; -- cgit v1.2.1 From 1f72c387c97fdf08b5736c8f23a01d047bb8e512 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Sun, 10 May 2015 23:07:35 +0200 Subject: Improve Git access error messages. --- lib/api/internal.rb | 26 +++++------------- lib/gitlab/git_access.rb | 61 +++++++++++++++++++++++++------------------ lib/gitlab/git_access_wiki.rb | 2 +- 3 files changed, 44 insertions(+), 45 deletions(-) diff --git a/lib/api/internal.rb b/lib/api/internal.rb index f98a17773e7..e38736fc28b 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -24,10 +24,6 @@ module API User.find_by(id: params[:user_id]) end - unless actor - return Gitlab::GitAccessStatus.new(false, 'No such user or key') - end - project_path = params[:project] # Check for *.wiki repositories. @@ -39,22 +35,14 @@ module API project = Project.find_with_namespace(project_path) - if project - access = - if wiki - Gitlab::GitAccessWiki.new(actor, project) - else - Gitlab::GitAccess.new(actor, project) - end - - status = access.check(params[:action], params[:changes]) - end + access = + if wiki + Gitlab::GitAccessWiki.new(actor, project) + else + Gitlab::GitAccess.new(actor, project) + end - if project && access.can_read_project? - status - else - Gitlab::GitAccessStatus.new(false, 'No such project') - end + access.check(params[:action], params[:changes]) end # diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index bc72b7528d5..c97249d49e2 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -31,8 +31,7 @@ module Gitlab def can_push_to_branch?(ref) return false unless user - if project.protected_branch?(ref) && - !(project.developers_can_push_to_protected_branch?(ref) && project.team.developer?(user)) + if project.protected_branch?(ref) && !project.developers_can_push_to_protected_branch?(ref) user.can?(:push_code_to_protected_branches, project) else user.can?(:push_code, project) @@ -50,13 +49,25 @@ module Gitlab end def check(cmd, changes = nil) + unless actor + return build_status_object(false, "No user or key was provided.") + end + + if user && !user_allowed? + return build_status_object(false, "Your account has been blocked.") + end + + unless project && can_read_project? + return build_status_object(false, 'The project you were looking for could not be found.') + end + case cmd when *DOWNLOAD_COMMANDS download_access_check when *PUSH_COMMANDS push_access_check(changes) else - build_status_object(false, "Wrong command") + build_status_object(false, "The command you're trying to execute is not allowed.") end end @@ -64,7 +75,7 @@ module Gitlab if user user_download_access_check elsif deploy_key - deploy_key_download_access_check + build_status_object(true) else raise 'Wrong actor' end @@ -74,39 +85,27 @@ module Gitlab if user user_push_access_check(changes) elsif deploy_key - build_status_object(false, "Deploy key not allowed to push") + build_status_object(false, "Deploy keys are not allowed to push code.") else raise 'Wrong actor' end end def user_download_access_check - if user && user_allowed? && user.can?(:download_code, project) - build_status_object(true) - else - build_status_object(false, "You don't have access") + unless user.can?(:download_code, project) + return build_status_object(false, "You are not allowed to download code from this project.") end - end - def deploy_key_download_access_check - if can_read_project? - build_status_object(true) - else - build_status_object(false, "Deploy key not allowed to access this project") - end + build_status_object(true) end def user_push_access_check(changes) - unless user && user_allowed? - return build_status_object(false, "You don't have access") - end - if changes.blank? return build_status_object(true) end unless project.repository.exists? - return build_status_object(false, "Repository does not exist") + return build_status_object(false, "A repository for this project does not exist yet.") end changes = changes.lines if changes.kind_of?(String) @@ -136,11 +135,23 @@ module Gitlab :push_code end - if user.can?(action, project) - build_status_object(true) - else - build_status_object(false, "You don't have permission") + unless user.can?(action, project) + return + case action + when :force_push_code_to_protected_branches + build_status_object(false, "You are not allowed to force push code to a protected branch on this project.") + when :remove_protected_branches + build_status_object(false, "You are not allowed to deleted protected branches from this project.") + when :push_code_to_protected_branches + build_status_object(false, "You are not allowed to push code to protected branches on this project.") + when :admin_project + build_status_object(false, "You are not allowed to change existing tags on this project.") + else # :push_code + build_status_object(false, "You are not allowed to push code to this project.") + end end + + build_status_object(true) end def forced_push?(oldrev, newrev) diff --git a/lib/gitlab/git_access_wiki.rb b/lib/gitlab/git_access_wiki.rb index 73d99b96202..8ba97184e69 100644 --- a/lib/gitlab/git_access_wiki.rb +++ b/lib/gitlab/git_access_wiki.rb @@ -4,7 +4,7 @@ module Gitlab if user.can?(:write_wiki, project) build_status_object(true) else - build_status_object(false, "You don't have access") + build_status_object(false, "You are not allowed to write to this project's wiki.") end end end -- cgit v1.2.1 From 9eb45ccd552c7c0a3c2104f01e86120d7c9f4060 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 12 May 2015 12:38:42 +0200 Subject: Improve description of branch protection levels. --- lib/gitlab/access.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/gitlab/access.rb b/lib/gitlab/access.rb index 424541b4a04..6d0e30e916f 100644 --- a/lib/gitlab/access.rb +++ b/lib/gitlab/access.rb @@ -51,9 +51,9 @@ module Gitlab def protection_options { - "Not protected, developers and masters can (force) push and delete the branch" => PROTECTION_NONE, - "Partially protected, developers can also push but prevent all force pushes and deletion" => PROTECTION_DEV_CAN_PUSH, - "Fully protected, only masters can push and prevent all force pushes and deletion" => PROTECTION_FULL, + "Not protected: Both developers and masters can push new commits, force push, or delete the branch." => PROTECTION_NONE, + "Partially protected: Developers can push new commits, but cannot force push or delete the branch. Masters can do all of those." => PROTECTION_DEV_CAN_PUSH, + "Fully protected: Developers cannot push new commits, force push, or delete the branch. Only masters can do any of those." => PROTECTION_FULL, } end -- cgit v1.2.1 From 17a41547a038fd2ecb8b00499541861383927344 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 12 May 2015 12:50:06 +0200 Subject: Improve OAuth signup error message. --- app/controllers/omniauth_callbacks_controller.rb | 11 +++++++++-- lib/gitlab/o_auth/user.rb | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index bb9d65c9ed6..dcd949a71de 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -65,8 +65,15 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController redirect_to omniauth_error_path(oauth['provider'], error: error_message) and return end end - rescue Gitlab::OAuth::ForbiddenAction => e - flash[:notice] = e.message + rescue Gitlab::OAuth::SignupDisabledError => e + message = "Signing in using your #{oauth['provider']} account without a pre-existing GitLab account is not allowed." + + if current_application_settings.signup_enabled? + message << " Create a GitLab account first, and then connect it to your #{oauth['provider']} account." + end + + flash[:notice] = message + redirect_to new_user_session_path end diff --git a/lib/gitlab/o_auth/user.rb b/lib/gitlab/o_auth/user.rb index 2f5c217d764..ba5caed6131 100644 --- a/lib/gitlab/o_auth/user.rb +++ b/lib/gitlab/o_auth/user.rb @@ -5,7 +5,7 @@ # module Gitlab module OAuth - class ForbiddenAction < StandardError; end + class SignupDisabledError < StandardError; end class User attr_accessor :auth_hash, :gl_user @@ -99,7 +99,7 @@ module Gitlab end def unauthorized_to_create - raise ForbiddenAction.new("Unauthorized to create user, signup disabled for #{auth_hash.provider}") + raise SignupDisabledError end end end -- cgit v1.2.1 From 0c4653e101df82fd94181269db2ffb4ba425bebb Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 12 May 2015 14:30:45 +0200 Subject: Improve OAuth application flash messages. --- config/locales/doorkeeper.en.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/locales/doorkeeper.en.yml b/config/locales/doorkeeper.en.yml index c5b6b75e7f6..a4032a21420 100644 --- a/config/locales/doorkeeper.en.yml +++ b/config/locales/doorkeeper.en.yml @@ -31,7 +31,7 @@ en: messages: # Common error messages invalid_request: 'The request is missing a required parameter, includes an unsupported parameter value, or is otherwise malformed.' - invalid_redirect_uri: 'The redirect uri included is not valid.' + invalid_redirect_uri: 'The redirect URI included is not valid.' unauthorized_client: 'The client is not authorized to perform this request using this method.' access_denied: 'The resource owner or authorization server denied the request.' invalid_scope: 'The requested scope is invalid, unknown, or malformed.' @@ -63,11 +63,11 @@ en: flash: applications: create: - notice: 'Application created.' + notice: 'The application was created successfully.' destroy: - notice: 'Application deleted.' + notice: 'The application was deleted successfully.' update: - notice: 'Application updated.' + notice: 'The application was updated successfully.' authorized_applications: destroy: - notice: 'Application revoked.' + notice: 'The application was revoked access.' -- cgit v1.2.1 From 1981174a1e80533d7a5bc5fd90e06adb67f1dc5d Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 12 May 2015 14:39:24 +0200 Subject: Fix 422 error page. --- public/422.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/422.html b/public/422.html index cad385ac153..026997b48e3 100644 --- a/public/422.html +++ b/public/422.html @@ -2,7 +2,7 @@ The change you requested was rejected (422) - + -- cgit v1.2.1 From c5e4b443ffdc1c094450d08d29bd96e43376d6d7 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 13 May 2015 09:45:34 +0200 Subject: Fix GitAccess. --- lib/gitlab/git_access.rb | 5 +++-- spec/lib/gitlab/git_access_spec.rb | 14 +++----------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index c97249d49e2..c90184d31cf 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -136,7 +136,7 @@ module Gitlab end unless user.can?(action, project) - return + status = case action when :force_push_code_to_protected_branches build_status_object(false, "You are not allowed to force push code to a protected branch on this project.") @@ -148,7 +148,8 @@ module Gitlab build_status_object(false, "You are not allowed to change existing tags on this project.") else # :push_code build_status_object(false, "You are not allowed to push code to this project.") - end + end + return status end build_status_object(true) diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb index 39be9d64644..c7291689e32 100644 --- a/spec/lib/gitlab/git_access_spec.rb +++ b/spec/lib/gitlab/git_access_spec.rb @@ -115,18 +115,10 @@ describe Gitlab::GitAccess do let(:actor) { key } context 'pull code' do - context 'allowed' do - before { key.projects << project } - subject { access.download_access_check } - - it { expect(subject.allowed?).to be_truthy } - end - - context 'denied' do - subject { access.download_access_check } + before { key.projects << project } + subject { access.download_access_check } - it { expect(subject.allowed?).to be_falsey } - end + it { expect(subject.allowed?).to be_truthy } end end end -- cgit v1.2.1