auth routes

This commit is contained in:
Puyodead1
2023-04-13 14:58:53 -04:00
parent 174d34c376
commit a567ca3f51
25 changed files with 230 additions and 74 deletions
+14 -4
View File
@@ -16,16 +16,26 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Router, Request, Response } from "express";
import { route } from "@spacebar/api";
import { BackupCode, generateToken, User, TotpSchema } from "@spacebar/util";
import { verifyToken } from "node-2fa";
import { BackupCode, TotpSchema, User, generateToken } from "@spacebar/util";
import { Request, Response, Router } from "express";
import { HTTPError } from "lambert-server";
import { verifyToken } from "node-2fa";
const router = Router();
router.post(
"/",
route({ body: "TotpSchema" }),
route({
body: "TotpSchema",
responses: {
200: {
body: "TokenResponse",
},
400: {
body: "APIErrorResponse",
},
},
}),
async (req: Request, res: Response) => {
// const { code, ticket, gift_code_sku_id, login_source } =
const { code, ticket } = req.body as TotpSchema;
+7 -1
View File
@@ -41,7 +41,13 @@ function toArrayBuffer(buf: Buffer) {
router.post(
"/",
route({ body: "WebAuthnTotpSchema" }),
route({
body: "WebAuthnTotpSchema",
responses: {
200: { body: "TokenResponse" },
400: { body: "APIErrorResponse" },
},
}),
async (req: Request, res: Response) => {
if (!WebAuthn.fido2) {
// TODO: I did this for typescript and I can't use !