This commit is contained in:
Your Name 2023-10-09 11:12:51 -04:00
parent f809500d17
commit 4f581d156b
1 changed files with 2 additions and 9 deletions

11
2fa.go
View File

@ -2,7 +2,6 @@ package scsusers
import ( import (
"crypto/rand" "crypto/rand"
"errors"
"fmt" "fmt"
"math/big" "math/big"
"strconv" "strconv"
@ -48,14 +47,8 @@ func Send2FA(u *UserData) error {
code := generate2fa() code := generate2fa()
u.Set("2fa", code) u.Set("2fa", code)
u.Set("2faexpires", fmt.Sprintf("%d", time.Now().Add(15*time.Minute).Unix())) u.Set("2faexpires", fmt.Sprintf("%d", time.Now().Add(15*time.Minute).Unix()))
firstname, ok := u.Get("firstname") firstname, _ := u.Get("firstname")
if !ok { lastname, _ := u.Get("lastname")
return errors.New("send2fa: no firstname")
}
lastname, ok := u.Get("lastname")
if !ok {
return errors.New("send2fa: no lastname")
}
fullname := fmt.Sprintf("%s %s", firstname, lastname) fullname := fmt.Sprintf("%s %s", firstname, lastname)
return Send2faEmail(u.Username, fullname, code) return Send2faEmail(u.Username, fullname, code)