2018-04-18 10:03:27 -04: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
|
|
|
|
if Gitlab::Auth::LDAP::Config.enabled?
|
|
|
|
devise_scope :user do
|
|
|
|
Gitlab::Auth::LDAP::Config.available_servers.each do |server|
|
|
|
|
override_omniauth(server['provider_name'], 'ldap/omniauth_callbacks')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-05 08:21:27 -04: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'
|
|
|
|
end
|
2016-10-06 08:14:24 -04:00
|
|
|
|
2018-04-26 07:28:24 -04:00
|
|
|
scope '-/users', module: :users do
|
|
|
|
resources :terms, only: [:index] do
|
|
|
|
post :accept, on: :member
|
|
|
|
post :decline, on: :member
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-24 16:59:26 -04:00
|
|
|
scope(constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }) do
|
2016-11-07 11:35:14 -05:00
|
|
|
scope(path: 'users/:username',
|
|
|
|
as: :user,
|
|
|
|
controller: :users) do
|
|
|
|
get :calendar
|
|
|
|
get :calendar_activities
|
|
|
|
get :groups
|
|
|
|
get :projects
|
|
|
|
get :contributed, as: :contributed_projects
|
|
|
|
get :snippets
|
|
|
|
get :exists
|
2018-10-04 03:55:37 -04:00
|
|
|
get :activity
|
2017-10-25 14:15:35 -04:00
|
|
|
get '/', to: redirect('%{username}'), as: nil
|
2016-11-07 11:35:14 -05:00
|
|
|
end
|
2016-10-12 11:49:41 -04:00
|
|
|
|
2016-11-07 11:35:14 -05:00
|
|
|
# Compatibility with old routing
|
|
|
|
# TODO (dzaporozhets): remove in 10.0
|
2017-10-25 14:15:35 -04:00
|
|
|
get '/u/:username', to: redirect('%{username}')
|
2016-11-07 11:35:14 -05:00
|
|
|
# TODO (dzaporozhets): remove in 9.0
|
2017-10-25 14:15:35 -04:00
|
|
|
get '/u/:username/groups', to: redirect('users/%{username}/groups')
|
|
|
|
get '/u/:username/projects', to: redirect('users/%{username}/projects')
|
|
|
|
get '/u/:username/snippets', to: redirect('users/%{username}/snippets')
|
|
|
|
get '/u/:username/contributed', to: redirect('users/%{username}/contributed')
|
2016-11-07 11:35:14 -05:00
|
|
|
end
|
2017-05-24 16:59:26 -04:00
|
|
|
|
2018-03-08 07:56:54 -05:00
|
|
|
constraints(::Constraints::UserUrlConstrainer.new) do
|
2017-05-24 16:59:26 -04:00
|
|
|
# Get all keys of user
|
|
|
|
get ':username.keys' => 'profiles/keys#get_keys', constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }
|
|
|
|
|
|
|
|
scope(path: ':username',
|
|
|
|
as: :user,
|
|
|
|
constraints: { username: Gitlab::PathRegex.root_namespace_route_regex },
|
|
|
|
controller: :users) do
|
|
|
|
get '/', action: :show
|
|
|
|
end
|
|
|
|
end
|