mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
fix(otp): crash after TOTP enroll
This commit is contained in:
parent
121287df21
commit
a91fe4b5ac
1 changed files with 2 additions and 8 deletions
|
@ -1,7 +1,6 @@
|
|||
package user
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
@ -89,13 +88,8 @@ func EnrollTOTP(c *gin.Context) {
|
|||
|
||||
t := time.Now().Unix()
|
||||
recoveryCodes := model.RecoveryCodes{Codes: generateRecoveryCodes(16), LastViewed: &t}
|
||||
codesJson, err := json.Marshal(&recoveryCodes)
|
||||
if err != nil {
|
||||
api.ErrHandler(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = u.Where(u.ID.Eq(cUser.ID)).Update(u.RecoveryCodes, codesJson)
|
||||
cUser.RecoveryCodes = recoveryCodes
|
||||
_, err = u.Where(u.ID.Eq(cUser.ID)).Updates(cUser)
|
||||
if err != nil {
|
||||
api.ErrHandler(c, err)
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue