oauth cleanup: test fakes and generic provider
This commit is contained in:
@ -10,11 +10,11 @@ class AuthController < ApplicationController
|
||||
end
|
||||
|
||||
def auth
|
||||
redirect_to client.auth_code.authorize_url(redirect_uri: ENV['gitlab_callback'])
|
||||
redirect_to client.auth_code.authorize_url(redirect_uri: ENV['callback_url'])
|
||||
end
|
||||
|
||||
def callback
|
||||
access_token = client.auth_code.get_token(params[:code], redirect_uri: ENV['gitlab_callback'])
|
||||
access_token = client.auth_code.get_token(params[:code], redirect_uri: ENV['callback_url'])
|
||||
session[:token] = access_token.token
|
||||
user_info(access_token)
|
||||
|
||||
@ -24,7 +24,7 @@ class AuthController < ApplicationController
|
||||
private
|
||||
|
||||
def user_info access_token
|
||||
@user_info ||= JSON.parse(access_token.get(ENV['gitlab_oauth'] + '/api/v3/user').body)
|
||||
@user_info ||= JSON.parse(access_token.get(ENV['oauth_path'] + '/api/v3/user').body)
|
||||
session[:name] = @user_info['name']
|
||||
session[:avatar] = @user_info['avatar_url']
|
||||
session[:admin] = @user_info['is_admin']
|
||||
@ -32,9 +32,9 @@ class AuthController < ApplicationController
|
||||
|
||||
def client
|
||||
OAuth2::Client.new(
|
||||
ENV['gitlab_client'],
|
||||
ENV['gitlab_secret'],
|
||||
site: ENV['gitlab_oauth']
|
||||
ENV['client_key'],
|
||||
ENV['secret_key'],
|
||||
site: ENV['oauth_path']
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -1 +1 @@
|
||||
<%= link_to "Authenticate with gitlab", auth_path %>
|
||||
<%= link_to "Authenticate with #{ENV['oauth_provider']}", auth_path %>
|
||||
|
Reference in New Issue
Block a user