diff --git a/client/src/components/App.tsx b/client/src/components/App.tsx index 9373b32..fe5eaea 100644 --- a/client/src/components/App.tsx +++ b/client/src/components/App.tsx @@ -13,6 +13,7 @@ import { Modal } from './Modal'; import { createClient } from '../util/apollo'; import { ApolloProvider } from '@apollo/client'; import { LogoutPage } from './LogoutPage'; +import { UnauthorizedPage } from './UnauthorizedPage/UnauthorizedPage'; export interface AppProps { @@ -41,6 +42,7 @@ export const App: FunctionComponent = () => { + diff --git a/client/src/components/UnauthorizedPage/UnauthorizedPage.tsx b/client/src/components/UnauthorizedPage/UnauthorizedPage.tsx new file mode 100644 index 0000000..4ad4db2 --- /dev/null +++ b/client/src/components/UnauthorizedPage/UnauthorizedPage.tsx @@ -0,0 +1,37 @@ +import React, { FunctionComponent } from 'react'; +import { Config } from '../../config'; +import { Page } from '../Page'; + +export interface UnauthorizedPageProps { + +} + +export const UnauthorizedPage:FunctionComponent = () => { + return ( + +
+
+
+
+
+
+

Non autorisé

+
+
+

Vous n'êtes pas autorisé à accéder à cette page.

+
+

Votre compte est peut être désactivé, votre adresse courriel ne fait peut être + pas partie des domaines autorisés ou vous n'avez peut être pas les droits nécessaires pour effectuer cette opération.

+ + +
+
+
+
+
+
+
+ ); +} \ No newline at end of file diff --git a/internal/route/login.go b/internal/route/login.go index 4582a45..158d016 100644 --- a/internal/route/login.go +++ b/internal/route/login.go @@ -1,7 +1,6 @@ package route import ( - "fmt" "net/http" "forge.cadoles.com/Cadoles/daddy/internal/auth" @@ -80,11 +79,8 @@ func handleLoginCallback(w http.ResponseWriter, r *http.Request) { } if !authorized { - message := fmt.Sprintf( - "You are not authorized to access this application. Disconnect by navigating to %s.", - "http://"+r.Host+"/logout", - ) - http.Error(w, message, http.StatusForbidden) + redirectURL := conf.HTTP.FrontendURL + "/unauthorized" + http.Redirect(w, r, redirectURL, http.StatusTemporaryRedirect) return } diff --git a/internal/route/mount.go b/internal/route/mount.go index b295101..1d047a4 100644 --- a/internal/route/mount.go +++ b/internal/route/mount.go @@ -72,10 +72,17 @@ func Mount(r *chi.Mux, config *config.Config) error { } // List of paths handled directly by the client - r.Get("/workgroups/*", serveClientIndex) - r.Get("/profile", serveClientIndex) - r.Get("/dashboard", serveClientIndex) - r.Get("/decisions/*", serveClientIndex) + clientRoutes := []string{ + "/workgroups/*", + "/profile", + "/dashboard", + "/decisions/*", + "/unauthorized", + } + + for _, cr := range clientRoutes { + r.Get(cr, serveClientIndex) + } // Serve static files notFoundHandler := r.NotFoundHandler()