1
0
Fork 0
mirror of https://git.42l.fr/neil/sncf.git synced 2024-05-09 17:26:36 +02:00

adding ALLOWED_ROUTES

This commit is contained in:
neil 2020-09-08 18:36:27 +02:00
parent cba8b52b32
commit 9f304c4069

View file

@ -61,6 +61,7 @@ pub fn check_new_form(body: &web::Bytes) -> u64 {
}
}
// those routes won't be redirected
const BLOCKED_ROUTES: &[&str] = &[
"/apps/settings",
"/login",
@ -70,6 +71,11 @@ const BLOCKED_ROUTES: &[&str] = &[
"/apps/files",
];
// ...except if they are in this list
const ALLOWED_ROUTES: &[&str] = &[
"/ocs/v2.php/apps/forms/",
];
// checks if the accessed route is allowed for the user.
// if it returns true, redirects elsewhere
pub fn check_route(route: &str) -> bool {
@ -77,6 +83,11 @@ pub fn check_route(route: &str) -> bool {
for r in BLOCKED_ROUTES {
if route.starts_with(r) {
for s in ALLOWED_ROUTES {
if route.starts_with(s) {
return false;
}
}
return true;
}
}