2019-11-19 10:06:24 -05:00
|
|
|
# frozen_string_literal: true
|
2019-06-24 12:53:17 -04:00
|
|
|
|
2021-07-12 11:09:19 -04:00
|
|
|
get 'unsubscribes/:email', to: 'users/unsubscribes#show', as: :unsubscribe
|
|
|
|
post 'unsubscribes/:email', to: 'users/unsubscribes#create'
|
|
|
|
|
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
|
2020-03-12 11:09:39 -04:00
|
|
|
if Gitlab::Auth::Ldap::Config.sign_in_enabled?
|
2018-04-18 10:03:27 -04:00
|
|
|
devise_scope :user do
|
2020-03-12 11:09:39 -04:00
|
|
|
Gitlab::Auth::Ldap::Config.available_servers.each do |server|
|
2018-04-18 10:03:27 -04:00
|
|
|
override_omniauth(server['provider_name'], 'ldap/omniauth_callbacks')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-09-14 20:09:30 -04:00
|
|
|
devise_controllers = { omniauth_callbacks: :omniauth_callbacks,
|
|
|
|
registrations: :registrations,
|
|
|
|
passwords: :passwords,
|
|
|
|
sessions: :sessions,
|
|
|
|
confirmations: :confirmations }
|
|
|
|
|
|
|
|
if ::Gitlab.ee? && ::Gitlab::Geo.connected? && ::Gitlab::Geo.secondary?
|
|
|
|
devise_for :users, controllers: devise_controllers, path_names: { sign_in: 'auth/geo/sign_in',
|
|
|
|
sign_out: 'auth/geo/sign_out' }
|
|
|
|
# When using Geo, the other type of routes should be present as well, as browsers
|
|
|
|
# cache 302 redirects locally, and events like primary going offline or a failover
|
|
|
|
# can result in browsers requesting the other paths because of it.
|
|
|
|
as :user do
|
|
|
|
get '/users/sign_in', to: 'sessions#new'
|
|
|
|
post '/users/sign_in', to: 'sessions#create'
|
|
|
|
post '/users/sign_out', to: 'sessions#destroy'
|
|
|
|
end
|
|
|
|
else
|
|
|
|
devise_for :users, controllers: devise_controllers
|
|
|
|
|
|
|
|
# We avoid drawing Geo routes for FOSS, but keep them in for EE
|
|
|
|
Gitlab.ee do
|
|
|
|
as :user do
|
|
|
|
get '/users/auth/geo/sign_in', to: 'sessions#new'
|
|
|
|
post '/users/auth/geo/sign_in', to: 'sessions#create'
|
|
|
|
post '/users/auth/geo/sign_out', to: 'sessions#destroy'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-10-05 08:21:27 -04:00
|
|
|
|
|
|
|
devise_scope :user do
|
|
|
|
get '/users/almost_there' => 'confirmations#almost_there'
|
2019-06-24 12:53:17 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
scope '-/users', module: :users do
|
|
|
|
resources :terms, only: [:index] do
|
|
|
|
post :accept, on: :member
|
|
|
|
post :decline, on: :member
|
|
|
|
end
|
2021-09-14 20:09:30 -04:00
|
|
|
|
|
|
|
resources :group_callouts, only: [:create]
|
2016-10-05 08:21:27 -04:00
|
|
|
end
|
2016-10-06 08:14:24 -04:00
|
|
|
|
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
|
2019-01-27 05:18:09 -05:00
|
|
|
get :starred, as: :starred_projects
|
2016-11-07 11:35:14 -05:00
|
|
|
get :snippets
|
2021-02-15 16:08:59 -05:00
|
|
|
get :followers
|
|
|
|
get :following
|
2016-11-07 11:35:14 -05:00
|
|
|
get :exists
|
2018-10-04 03:55:37 -04:00
|
|
|
get :activity
|
2021-02-15 16:08:59 -05:00
|
|
|
post :follow
|
|
|
|
post :unfollow
|
2017-10-25 14:15:35 -04:00
|
|
|
get '/', to: redirect('%{username}'), as: nil
|
2016-11-07 11:35:14 -05:00
|
|
|
end
|
|
|
|
end
|
2017-05-24 16:59:26 -04:00
|
|
|
|
2018-03-08 07:56:54 -05:00
|
|
|
constraints(::Constraints::UserUrlConstrainer.new) do
|
2020-12-03 13:10:10 -05:00
|
|
|
# Get all SSH keys of user
|
2020-12-11 13:09:57 -05:00
|
|
|
get ':username.keys' => 'users#ssh_keys', constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }
|
2017-05-24 16:59:26 -04:00
|
|
|
|
2020-12-03 13:10:10 -05:00
|
|
|
# Get all GPG keys of user
|
2021-08-30 05:09:12 -04:00
|
|
|
get ':username.gpg' => 'users#gpg_keys', as: 'user_gpg_keys', constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }
|
2020-12-03 13:10:10 -05:00
|
|
|
|
2017-05-24 16:59:26 -04:00
|
|
|
scope(path: ':username',
|
|
|
|
as: :user,
|
|
|
|
constraints: { username: Gitlab::PathRegex.root_namespace_route_regex },
|
|
|
|
controller: :users) do
|
|
|
|
get '/', action: :show
|
|
|
|
end
|
|
|
|
end
|