Gestion des utilisateurs

This commit is contained in:
William Bouzourène 2025-01-02 21:18:56 +01:00
parent 157c33227e
commit 9d25ca20df
14 changed files with 576 additions and 26 deletions

View file

@ -28,10 +28,10 @@ func TotpEnrollPage(c *fiber.Ctx) error {
result := db.First(&user, "id = ?", userid)
if result.Error != nil {
return err
return result.Error
}
if user.TotpSercet.Valid {
if user.TotpSecret.Valid {
return fiber.NewError(fiber.StatusForbidden, "Forbidden")
}
@ -79,7 +79,7 @@ func TotpEnrollPage(c *fiber.Ctx) error {
if c.Method() == "POST" {
otp := c.FormValue("otp")
if totp.Validate(otp, key.Secret()) {
err = user.TotpSercet.Scan(key.Secret())
err = user.TotpSecret.Scan(key.Secret())
if err != nil {
return err
}
@ -152,17 +152,17 @@ func TotpVerifyPage(c *fiber.Ctx) error {
result := db.First(&user, "id = ?", userid)
if result.Error != nil {
return err
return result.Error
}
if !user.TotpSercet.Valid {
if !user.TotpSecret.Valid {
return fiber.NewError(fiber.StatusForbidden, "Forbidden")
}
var mfaError string
if c.Method() == "POST" {
otp := c.FormValue("otp")
if totp.Validate(otp, user.TotpSercet.String) {
if totp.Validate(otp, user.TotpSecret.String) {
redirectId := c.Query("redirect")
redirectUrl := "/"