An entire complete sign in user flow

This commit is contained in:
2024-04-21 01:33:42 +08:00
parent e79441dbc5
commit ee6e7324b2
21 changed files with 467 additions and 52 deletions

View File

@ -3,6 +3,8 @@ package utils
import (
"github.com/go-playground/validator/v10"
"github.com/gofiber/fiber/v2"
"github.com/samber/lo"
"github.com/sujit-baniya/flash"
)
var validation = validator.New(validator.WithRequiredStructEnabled())
@ -16,3 +18,15 @@ func BindAndValidate(c *fiber.Ctx, out any) error {
return nil
}
func GetRedirectUri(c *fiber.Ctx, fallback ...string) *string {
if len(c.Query("redirect_uri")) > 0 {
return lo.ToPtr(c.Query("redirect_uri"))
} else if val, ok := flash.Get(c)["redirect_uri"].(*string); ok {
return val
} else if len(fallback) > 0 {
return &fallback[0]
} else {
return nil
}
}