-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(AdminUserPanel): add reset auth option (fixes #410)
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { Response, Request } from "express"; | ||
import { Auth } from "../../lib/Auth.js"; | ||
import type { Middleware, RequestMethods } from "../../lib/types.js"; | ||
import type Server from "../../Server.js"; | ||
|
||
export default async function handler(server: Server, req: Request, res: Response) { | ||
try { | ||
const { domain: domainName } = req.body; | ||
if (typeof domainName !== "string") { | ||
res.status(400).send({ message: "Invalid domain provided." }); | ||
return; | ||
} | ||
|
||
const domain = server.domains.get(domainName); | ||
if (!domain) { | ||
res.status(400).send({ message: "Invalid domain provided." }); | ||
return; | ||
} | ||
|
||
await domain.resetAuth(); | ||
res.sendStatus(204); | ||
} catch (err) { | ||
server.logger.fatal(`[RESET:POST]: Fatal error while resetting the encryption key`, err); | ||
res.status(500).send({ message: "Internal server error occured, please try again later." }); | ||
} | ||
} | ||
|
||
export const methods: RequestMethods[] = ["post"]; | ||
export const middleware: Middleware[] = [Auth.adminMiddleware.bind(Auth)]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters