♻️ Rework authentication
- Move login endpoint `/login` to `/auth/login` - Add logout route `/auth/logout` - Add `/api/token` endpoint and `?token=` query parameter for auth - Refactor `auth.js`
This commit is contained in:
@ -34,7 +34,8 @@ new Parser(
|
||||
);
|
||||
|
||||
// Create new Auth class to store sessions
|
||||
app.post("/login", auth.login);
|
||||
app.post("/auth/login", auth.login);
|
||||
app.get("/auth/logout", auth.logout);
|
||||
// Check login for every API request
|
||||
app.use("/api", auth.checkLogin);
|
||||
// Provide check endpoint so the frontend
|
||||
@ -48,6 +49,7 @@ app.get("/api/timetable", getTimetable);
|
||||
app.get("/api/substitutions", getSubstitutions);
|
||||
app.get("/api/history", getHistory);
|
||||
app.get("/api/classes", getClasses);
|
||||
app.post("/api/token", auth.token);
|
||||
// Respond with 400 for non-existent endpoints
|
||||
app.get("/api/*", (_req, res) => {
|
||||
res.sendStatus(400);
|
||||
|
Reference in New Issue
Block a user