When not logged in redirection to login page

Every page is locked behind a jwt, when it is not supplied neither other
pages not api calls will work
This commit is contained in:
2026-05-01 16:18:15 +02:00
parent b672fe9768
commit e54be14526
8 changed files with 221 additions and 68 deletions

View File

@@ -1,5 +1,7 @@
mod pages;
mod auth;
use crate::pages::*;
use crate::auth::ProtectedRoute;
use yew::prelude::*;
use yew_router::prelude::*;
@@ -28,15 +30,43 @@ enum Route {
fn switch(route: Route) -> Html {
match route {
Route::Home => html! { <basic_pages::Home/>},
Route::Home => html! {
<ProtectedRoute>
<basic_pages::Home/>
</ProtectedRoute>
},
Route::NotFound => html! { <basic_pages::NotFound/> },
Route::Ticket => html! { <ticket::SubmitTicket/> },
Route::TicketById { id } => html! { <ticket::TicketByID id={id}/> },
Route::AllTickets => html! { <ticket::AllTickets/> },
Route::Register => html! { <user::Register/> },
Route::Ticket => html! {
<ProtectedRoute>
<ticket::SubmitTicket/>
</ProtectedRoute>
},
Route::TicketById { id } => html! {
<ProtectedRoute>
<ticket::TicketByID {id}/>
</ProtectedRoute>
},
Route::AllTickets => html! {
<ProtectedRoute>
<ticket::AllTickets/>
</ProtectedRoute>
},
Route::Register => html! {
<ProtectedRoute>
<user::Register/>
</ProtectedRoute>
},
Route::Login => html! { <user::Login/> },
Route::AllUsers => html! {<user::AllUsers/>},
Route::UserByID { id } => html! { <user::UserByID id={id}/> },
Route::AllUsers => html! {
<ProtectedRoute>
<user::AllUsers/>
</ProtectedRoute>
},
Route::UserByID { id } => html! {
<ProtectedRoute>
<user::UserByID {id}/>
</ProtectedRoute>
},
}
}