Gestion des utilisateurs
This commit is contained in:
parent
7d71923d4f
commit
efd8912648
14 changed files with 576 additions and 26 deletions
|
|
@ -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 := "/"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue