diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-05-09 20:47:06 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-05-09 20:47:06 +0300 |
commit | daca2144c80546169fb35fcf76b1f3d052b643cc (patch) | |
tree | cd4a4b86fc82ef7085704e8c383f66b6ef3f4122 /app/controllers/jwt_controller.rb | |
parent | 9f679ac2079dc1d412aaaed806c3d06bdc071046 (diff) | |
download | gitlab-ce-daca2144c80546169fb35fcf76b1f3d052b643cc.tar.gz |
Make code more clear in what is done
Diffstat (limited to 'app/controllers/jwt_controller.rb')
-rw-r--r-- | app/controllers/jwt_controller.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/app/controllers/jwt_controller.rb b/app/controllers/jwt_controller.rb index 2a92627cb1b..9bf1ddbba21 100644 --- a/app/controllers/jwt_controller.rb +++ b/app/controllers/jwt_controller.rb @@ -8,8 +8,9 @@ class JwtController < ApplicationController def auth @authenticated = authenticate_with_http_basic do |login, password| - @ci_project = ci_project(login, password) - @user = authenticate_user(login, password) unless @ci_project + # if it's possible we first try to authenticate project with login and password + @project = authenticate_project(login, password) + @user = authenticate_user(login, password) unless @project end unless @authenticated @@ -19,7 +20,7 @@ class JwtController < ApplicationController service = SERVICES[params[:service]] head :not_found unless service - result = service.new(@ci_project, @user, auth_params).execute + result = service.new(@project, @user, auth_params).execute return head result[:http_status] if result[:http_status] render json: result @@ -31,7 +32,7 @@ class JwtController < ApplicationController params.permit(:service, :scope, :offline_token, :account, :client_id) end - def ci_project(login, password) + def authenticate_project(login, password) matched_login = /(?<s>^[a-zA-Z]*-ci)-token$/.match(login) if matched_login.present? |