package scsusers import ( "fmt" "log" "time" "golang.org/x/crypto/bcrypt" ) func RecoverByEmail(email string) { u, ok := Get(email) if !ok { return } recoverycode := generatePassword(16) u.Delete("recoverycode") u.Delete("recoverytime") crypt, err := bcrypt.GenerateFromPassword(recoverycode, 10) if err != nil { log.Println("pass generation failed") return } u.Set("recoverycode", string(crypt)) u.Set("recoverytime", fmt.Sprintf("%d", time.Now().Add(time.Minute*60).Unix())) SendRecoveryEmail(email, email, string(recoverycode)) }