From 38ee30f4556740812d0538e2033148012252bc17 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 26 Jun 2024 18:18:04 +0800 Subject: [PATCH] :sparkles: Can pick up mfa request --- .idea/dataSources.local.xml | 2 +- .../74bcf3ef-a2b9-435b-b9e5-f32902a33b25.xml | 2 +- .idea/workspace.xml | 15 +++++++++----- pkg/internal/server/api/auth_api.go | 14 +++++++++++++ pkg/internal/server/api/index.go | 2 ++ web/src/layouts/master.vue | 2 +- web/src/layouts/user-center.vue | 4 ++-- web/src/router/index.ts | 1 + web/src/views/auth/sign-in.vue | 20 ++++++++++++++++++- web/src/views/personalize.vue | 2 +- 10 files changed, 52 insertions(+), 12 deletions(-) diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml index 43b3037..6bea2b4 100644 --- a/.idea/dataSources.local.xml +++ b/.idea/dataSources.local.xml @@ -2,7 +2,7 @@ - + " diff --git a/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25.xml b/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25.xml index fc6cb23..4ae7c0d 100644 --- a/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25.xml +++ b/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25.xml @@ -12,7 +12,7 @@ 4||10|C|G 4||10|T|G 7430 - 16.2 + 16.3 1716108620 true ACDT true ACSST diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 26431f1..855666b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,11 +4,16 @@ - + + - - + + + + + + - @@ -171,7 +175,8 @@ - true diff --git a/pkg/internal/server/api/auth_api.go b/pkg/internal/server/api/auth_api.go index 5104dde..bb8af6a 100644 --- a/pkg/internal/server/api/auth_api.go +++ b/pkg/internal/server/api/auth_api.go @@ -10,6 +10,20 @@ import ( "git.solsynth.dev/hydrogen/passport/pkg/internal/services" ) +func getTicket(c *fiber.Ctx) error { + ticketId, err := c.ParamsInt("ticketId") + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, "ticket id is required") + } + + ticket, err := services.GetTicket(uint(ticketId)) + if err != nil { + return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("ticket %d not found", ticketId)) + } else { + return c.JSON(ticket) + } +} + func doAuthenticate(c *fiber.Ctx) error { var data struct { Username string `json:"username" validate:"required"` diff --git a/pkg/internal/server/api/index.go b/pkg/internal/server/api/index.go index 739e58e..223fd80 100644 --- a/pkg/internal/server/api/index.go +++ b/pkg/internal/server/api/index.go @@ -59,6 +59,8 @@ func MapAPIs(app *fiber.App) { auth.Post("/mfa", doMultiFactorAuthenticate) auth.Post("/token", getToken) + auth.Get("/tickets/:ticketId", getTicket) + auth.Get("/factors", getAvailableFactors) auth.Post("/factors/:factorId", requestFactorToken) diff --git a/web/src/layouts/master.vue b/web/src/layouts/master.vue index 6c8ef89..fe42bd5 100755 --- a/web/src/layouts/master.vue +++ b/web/src/layouts/master.vue @@ -1,5 +1,5 @@