debian-mirror-gitlab/config/routes/user.rb

124 lines
4.4 KiB
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
2019-09-30 21:07:59 +05:30
2021-09-30 23:02:18 +05:30
get 'unsubscribes/:email', to: 'users/unsubscribes#show', as: :unsubscribe
post 'unsubscribes/:email', to: 'users/unsubscribes#create'
2018-10-15 14:42:47 +05:30
# 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-04-08 14:13:33 +05:30
if Gitlab::Auth::Ldap::Config.sign_in_enabled?
2018-10-15 14:42:47 +05:30
devise_scope :user do
2022-08-13 15:12:31 +05:30
Gitlab::Auth::Ldap::Config.servers.each do |server|
2018-10-15 14:42:47 +05:30
override_omniauth(server['provider_name'], 'ldap/omniauth_callbacks')
end
end
end
2021-11-11 11:23:49 +05:30
devise_controllers = { omniauth_callbacks: :omniauth_callbacks,
registrations: :registrations,
passwords: :passwords,
sessions: :sessions,
confirmations: :confirmations }
2022-07-16 23:28:13 +05:30
if ::Gitlab.ee? && ::Gitlab::Geo.secondary?(infer_without_database: true)
2021-11-11 11:23:49 +05:30
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-11-03 12:29:30 +05:30
devise_scope :user do
get '/users/almost_there' => 'confirmations#almost_there'
2022-08-13 15:12:31 +05:30
post '/users/resend_verification_code', to: 'sessions#resend_verification_code'
get '/users/successful_verification', to: 'sessions#successful_verification'
2023-03-04 22:38:38 +05:30
# Redirect on GitHub authorization request errors. E.g. it could happen when user:
# 1. cancel authorization the GitLab OAuth app via GitHub to import GitHub repos
# (they'll be redirected to /projects/new#import_project)
# 2. cancel signing in to GitLab using GitHub account
# (they'll be redirected to /users/sign_in)
# In these cases, GitHub redirects user to the GitLab OAuth app's
# registered callback URL - /users/auth, which is the url to the auth user's profile page
get '/users/auth',
constraints: ->(req) {
req.params[:error].present? && req.params[:state].present?
},
to: redirect { |_params, req|
redirect_path = req.session.delete(:auth_on_failure_path)
redirect_path || Rails.application.routes.url_helpers.new_user_session_path
}
2019-09-30 21:07:59 +05:30
end
scope '-/users', module: :users do
resources :terms, only: [:index] do
post :accept, on: :member
post :decline, on: :member
end
2021-11-11 11:23:49 +05:30
2022-01-26 12:08:38 +05:30
resources :callouts, only: [:create]
2021-11-11 11:23:49 +05:30
resources :group_callouts, only: [:create]
2022-08-27 11:52:29 +05:30
resources :project_callouts, only: [:create]
2023-06-20 00:43:36 +05:30
resource :pins, only: [:update]
2016-11-03 12:29:30 +05:30
end
2017-09-10 17:25:29 +05:30
scope(constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }) do
2023-06-20 00:43:36 +05:30
scope(path: 'users/:username', as: :user, controller: :users) do
2017-08-17 22:00:37 +05:30
get :calendar
get :calendar_activities
get :groups
get :projects
get :contributed, as: :contributed_projects
2019-10-12 21:52:04 +05:30
get :starred, as: :starred_projects
2017-08-17 22:00:37 +05:30
get :snippets
2021-03-11 19:13:27 +05:30
get :followers
get :following
2017-08-17 22:00:37 +05:30
get :exists
2018-12-05 23:21:45 +05:30
get :activity
2021-03-11 19:13:27 +05:30
post :follow
post :unfollow
2018-03-17 18:26:18 +05:30
get '/', to: redirect('%{username}'), as: nil
2017-08-17 22:00:37 +05:30
end
end
2017-09-10 17:25:29 +05:30
2018-05-09 12:01:36 +05:30
constraints(::Constraints::UserUrlConstrainer.new) do
2021-02-22 17:27:13 +05:30
# Get all SSH keys of user
get ':username.keys' => 'users#ssh_keys', constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }
# Get all GPG keys of user
2021-11-11 11:23:49 +05:30
get ':username.gpg' => 'users#gpg_keys', as: 'user_gpg_keys', constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }
2017-09-10 17:25:29 +05:30
2023-06-20 00:43:36 +05:30
scope(
path: ':username',
as: :user,
constraints: { username: Gitlab::PathRegex.root_namespace_route_regex },
controller: :users
) do
2017-09-10 17:25:29 +05:30
get '/', action: :show
end
end