Skip to content

Commit

Permalink
Renommer 'insider' par 'academic'
Browse files Browse the repository at this point in the history
  • Loading branch information
tnicolas1 committed Feb 5, 2025
1 parent 2198dcb commit 29b3e0b
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

module Insider
module Academic
class ApplicationController < ActionController::Base
include UserLogger
include PageTitle

layout "application"

before_action :authenticate_insider_user!, except: :login
before_action :authenticate_academic_user!, except: :login
before_action :log_user,
:set_overrides,
:infer_page_title
Expand All @@ -19,19 +19,19 @@ def home; end
def login; end

def logout
sign_out(current_insider_user)
sign_out(current_academic_user)

redirect_to after_sign_out_path_for(:insider_user)
redirect_to after_sign_out_path_for(:academic_user)
end

protected

def after_sign_out_path_for(_resource)
new_insider_user_session_path
new_academic_user_session_path
end

def current_user
current_insider_user
current_academic_user
end

def current_establishment
Expand All @@ -40,7 +40,7 @@ def current_establishment

def set_overrides
@inhibit_nav = true
@logout_path = :destroy_insider_user_session
@logout_path = :destroy_academic_user_session
end
end
end
10 changes: 5 additions & 5 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ApplicationController < ActionController::Base
before_action :authenticate_user!,
:log_user,
:redirect_asp_users!,
:redirect_insider_users!,
:redirect_academic_users!,
:check_maintenance,
:check_current_establishment

Expand All @@ -25,8 +25,8 @@ def after_sign_out_path_for(resource_or_scope)
new_user_session_path
when :asp_user
new_asp_user_session_path
when :insider_user
new_insider_user_session_path
when :academic_user
new_academic_user_session_path
end
end

Expand Down Expand Up @@ -55,8 +55,8 @@ def redirect_asp_users!
redirect_to asp_schoolings_path and return if asp_user_signed_in?
end

def redirect_insider_users!
redirect_to insider_home_path and return if insider_user_signed_in?
def redirect_academic_users!
redirect_to academic_home_path and return if academic_user_signed_in?
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/developer_oidc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def static_info(attrs)
name: "Developer Account",
email: attrs["info"]["email"]
},
callback: attrs["info"]["insider"]
callback: attrs["info"]["academic"]
}
end

Expand Down
22 changes: 11 additions & 11 deletions app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def fim
end

def oidc
if auth_hash.info.callback&.to_sym.eql?(:insider)
oidc_insider
if auth_hash.info.callback&.to_sym.eql?(:academic)
oidc_academic
else
oidc_aplypro
end
Expand All @@ -58,15 +58,15 @@ def oidc_aplypro
choose_redirect_page!
end

def oidc_insider
@insider_login = true
@insider_user = Insider::User.from_oidc(auth_hash).tap(&:save!)
def oidc_academic
@academic_login = true
@academic_user = Academic::User.from_oidc(auth_hash).tap(&:save!)

# TODO: Check limited access to this part ?

sign_in(:insider_user, @insider_user)
sign_in(:academic_user, @academic_user)

redirect_to insider_home_path
redirect_to academic_home_path
end

def failure
Expand All @@ -82,8 +82,8 @@ def authentication_failure(error)

if defined? @asp_login
fail_asp_user
elsif defined? @insider_login
fail_insider_user
elsif defined? @academic_login
fail_academic_user
else
fail_user
end
Expand All @@ -99,8 +99,8 @@ def fail_asp_user
redirect_to new_asp_user_session_path
end

def fail_insider_user
redirect_to new_insider_user_session_path
def fail_academic_user
redirect_to new_academic_user_session_path
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/models/insider/user.rb → app/models/academic/user.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module Insider
module Academic
class User < ApplicationRecord
devise :authenticatable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
description: t("omniauth.#{provider}.description"),
button: t("omniauth.#{provider}.button"),
path: "/users/auth/#{provider}",
callback: :insider
callback: :academic
2 changes: 1 addition & 1 deletion config/initializers/omniauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
:email,
{ "Portail de connexion" => portals },
{ "Role assumé" => ["Personnel de direction", "Personnel autorisé"] },
{ callback: %w[aplypro insider] }
{ callback: %w[aplypro academic] }
]
end

Expand Down
2 changes: 1 addition & 1 deletion config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ fr:
schoolings:
index: Recherche d'un dossier
show: "Dossier %{attributive_decision_number}"
insider:
academic:
application:
login: Connexion à APLyPro
home : Accueil
Expand Down
12 changes: 6 additions & 6 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@

delete "asp/logout", to: "asp/application#logout", as: :destroy_asp_user_session

namespace :insider do
namespace :academic do
get "home", to: "application#home"

devise_for :users, skip: :all, class_name: "Insider::User"
devise_for :users, skip: :all, class_name: "Academic::User"
end

get "insider/login", to: "insider/application#login", as: :new_insider_user_session
get "academic/login", to: "academic/application#login", as: :new_academic_user_session

delete "insider/logout", to: "insider/application#logout", as: :destroy_insider_user_session
delete "academic/logout", to: "academic/application#logout", as: :destroy_academic_user_session

resources :users, only: :update do
get "select_establishment"
Expand Down Expand Up @@ -113,8 +113,8 @@
get "/auth/asp/callback" => "users/omniauth_callbacks#asp", as: :asp_login
end

devise_scope :insider_user do
get "/auth/insider/callback" => "users/omniauth_callbacks#insider", as: :insider_login
devise_scope :academic_user do
get "/auth/academic/callback" => "users/omniauth_callbacks#academic", as: :academic_login
end

devise_for :users
Expand Down

0 comments on commit 29b3e0b

Please sign in to comment.