auth routes

This commit is contained in:
Puyodead1
2023-04-13 14:58:53 -04:00
parent 174d34c376
commit a567ca3f51
25 changed files with 25602 additions and 9824 deletions
+12 -1
View File
@@ -37,9 +37,20 @@ async function getToken(user: User) {
return { token };
}
// TODO: the response interface also returns settings, but this route doesn't actually return that.
router.post(
"/",
route({ body: "VerifyEmailSchema" }),
route({
body: "VerifyEmailSchema",
responses: {
200: {
body: "TokenResponse",
},
400: {
body: "APIErrorOrCaptchaResponse",
},
},
}),
async (req: Request, res: Response) => {
const { captcha_key, token } = req.body;
+8 -1
View File
@@ -24,7 +24,14 @@ const router = Router();
router.post(
"/",
route({ right: "RESEND_VERIFICATION_EMAIL" }),
route({
right: "RESEND_VERIFICATION_EMAIL",
responses: {
204: {},
400: {},
500: {},
},
}),
async (req: Request, res: Response) => {
const user = await User.findOneOrFail({
where: { id: req.user_id },
@@ -16,15 +16,21 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Router, Request, Response } from "express";
import { route } from "@spacebar/api";
import { FieldErrors, User, BackupCodesChallengeSchema } from "@spacebar/util";
import { BackupCodesChallengeSchema, FieldErrors, User } from "@spacebar/util";
import bcrypt from "bcrypt";
import { Request, Response, Router } from "express";
const router = Router();
router.post(
"/",
route({ body: "BackupCodesChallengeSchema" }),
route({
body: "BackupCodesChallengeSchema",
responses: {
200: { body: "BackupCodesChallengeResponse" },
400: { body: "APIErrorResponse" },
},
}),
async (req: Request, res: Response) => {
const { password } = req.body as BackupCodesChallengeSchema;