2019-11-19 15:06:24 +00:00
|
|
|
# frozen_string_literal: true
|
2019-06-24 16:53:17 +00:00
|
|
|
|
2018-04-18 14:03:27 +00:00
|
|
|
# Allows individual providers to be directed to a chosen controller
|
|
|
|
# Call from inside devise_scope
|
|
|
|
def override_omniauth(provider, controller, path_prefix = '/users/auth')
|
|
|
|
match "#{path_prefix}/#{provider}/callback",
|
|
|
|
to: "#{controller}##{provider}",
|
|
|
|
as: "#{provider}_omniauth_callback",
|
|
|
|
via: [:get, :post]
|
|
|
|
end
|
|
|
|
|
|
|
|
# Use custom controller for LDAP omniauth callback
|
2020-03-12 15:09:39 +00:00
|
|
|
if Gitlab::Auth::Ldap::Config.sign_in_enabled?
|
2018-04-18 14:03:27 +00:00
|
|
|
devise_scope :user do
|
2020-03-12 15:09:39 +00:00
|
|
|
Gitlab::Auth::Ldap::Config.available_servers.each do |server|
|
2018-04-18 14:03:27 +00:00
|
|
|
override_omniauth(server['provider_name'], 'ldap/omniauth_callbacks')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-05 12:21:27 +00:00
|
|
|
devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks,
|
|
|
|
registrations: :registrations,
|
|
|
|
passwords: :passwords,
|
|
|
|
sessions: :sessions,
|
|
|
|
confirmations: :confirmations }
|
|
|
|
|
|
|
|
devise_scope :user do
|
|
|
|
get '/users/auth/:provider/omniauth_error' => 'omniauth_callbacks#omniauth_error', as: :omniauth_error
|
|
|
|
get '/users/almost_there' => 'confirmations#almost_there'
|
2019-06-24 16:53:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
scope '-/users', module: :users do
|
|
|
|
resources :terms, only: [:index] do
|
|
|
|
post :accept, on: :member
|
|
|
|
post :decline, on: :member
|
|
|
|
end
|
2016-10-05 12:21:27 +00:00
|
|
|
end
|
2016-10-06 12:14:24 +00:00
|
|
|
|
2017-05-24 20:59:26 +00:00
|
|
|
scope(constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }) do
|
2016-11-07 16:35:14 +00:00
|
|
|
scope(path: 'users/:username',
|
|
|
|
as: :user,
|
|
|
|
controller: :users) do
|
|
|
|
get :calendar
|
|
|
|
get :calendar_activities
|
|
|
|
get :groups
|
|
|
|
get :projects
|
|
|
|
get :contributed, as: :contributed_projects
|
2019-01-27 10:18:09 +00:00
|
|
|
get :starred, as: :starred_projects
|
2016-11-07 16:35:14 +00:00
|
|
|
get :snippets
|
|
|
|
get :exists
|
2019-11-01 12:06:26 +00:00
|
|
|
get :suggests
|
2018-10-04 07:55:37 +00:00
|
|
|
get :activity
|
2017-10-25 18:15:35 +00:00
|
|
|
get '/', to: redirect('%{username}'), as: nil
|
2016-11-07 16:35:14 +00:00
|
|
|
end
|
|
|
|
end
|
2017-05-24 20:59:26 +00:00
|
|
|
|
2018-03-08 12:56:54 +00:00
|
|
|
constraints(::Constraints::UserUrlConstrainer.new) do
|
2017-05-24 20:59:26 +00:00
|
|
|
# Get all keys of user
|
2020-07-01 18:08:50 +00:00
|
|
|
get ':username.keys', controller: :users, action: :ssh_keys, constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }
|
2017-05-24 20:59:26 +00:00
|
|
|
|
|
|
|
scope(path: ':username',
|
|
|
|
as: :user,
|
|
|
|
constraints: { username: Gitlab::PathRegex.root_namespace_route_regex },
|
|
|
|
controller: :users) do
|
|
|
|
get '/', action: :show
|
|
|
|
end
|
|
|
|
end
|