BigW Consortium Gitlab

user.rb 1.72 KB
Newer Older
1 2
require 'constraints/user_url_constrainer'

3 4 5 6 7 8 9 10 11 12
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
13 14

constraints(UserUrlConstrainer.new) do
15 16 17
  # Get all keys of user
  get ':username.keys' => 'profiles/keys#get_keys', constraints: { username: Gitlab::Regex.namespace_route_regex }

18 19
  scope(path: ':username',
        as: :user,
20
        constraints: { username: Gitlab::Regex.namespace_route_regex },
21
        controller: :users) do
22 23 24 25
    get '/', action: :show
  end
end

26 27 28 29 30 31 32 33 34 35 36 37 38
scope(constraints: { username: Gitlab::Regex.namespace_route_regex }) do
  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
    get '/', to: redirect('/%{username}')
  end
39

40 41 42 43 44 45 46 47 48
  # Compatibility with old routing
  # TODO (dzaporozhets): remove in 10.0
  get '/u/:username', to: redirect('/%{username}')
  # TODO (dzaporozhets): remove in 9.0
  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')
end