login and authentication
login via totp authentication via access and refresh tokens
This commit is contained in:
parent
6696975bee
commit
e1ec65350d
28 changed files with 3750 additions and 0 deletions
22
src/routes/auth.ts
Normal file
22
src/routes/auth.ts
Normal file
|
@ -0,0 +1,22 @@
|
|||
import express from "express";
|
||||
import { login, logout, refresh, register } from "../controller/authController";
|
||||
|
||||
var router = express.Router({ mergeParams: true });
|
||||
|
||||
router.post("/login", async (req, res) => {
|
||||
await login(req, res);
|
||||
});
|
||||
|
||||
router.post("/logout", async (req, res) => {
|
||||
await logout(req, res);
|
||||
});
|
||||
|
||||
router.post("/refresh", async (req, res) => {
|
||||
await refresh(req, res);
|
||||
});
|
||||
|
||||
router.post("/register", async (req, res) => {
|
||||
await register(req, res);
|
||||
});
|
||||
|
||||
export default router;
|
27
src/routes/index.ts
Normal file
27
src/routes/index.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import express from "express";
|
||||
import cors from "cors";
|
||||
|
||||
import type { Express } from "express";
|
||||
import errorHandler from "../middleware/errorHandler";
|
||||
import authenticate from "../middleware/authenticate";
|
||||
|
||||
import auth from "./auth";
|
||||
|
||||
export default (app: Express) => {
|
||||
app.set("query parser", "extended");
|
||||
app.use(express.json());
|
||||
app.use(
|
||||
express.urlencoded({
|
||||
extended: true,
|
||||
})
|
||||
);
|
||||
app.use(cors());
|
||||
app.options("*", cors());
|
||||
|
||||
app.use("/auth", auth);
|
||||
app.use(authenticate);
|
||||
app.use("/secured", (req, res) => {
|
||||
res.send("hallo");
|
||||
});
|
||||
app.use(errorHandler);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue