mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-26 19:16:24 +00:00
feat: add email verification and password reset functionality
- Introduced environment variables for database and email configurations. - Implemented email verification code generation and validation. - Added password reset feature with email verification. - Updated user registration and profile management APIs. - Refactored user security settings to include email and password updates. - Enhanced console layout with internationalization support. - Removed deprecated settings page and integrated global settings. - Added new reset password page and form components. - Updated localization files for new features and translations.
This commit is contained in:
@ -1 +1,27 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/snowykami/neo-blog/pkg/constant"
|
||||
)
|
||||
|
||||
func RequestEmailVerify(email string) string {
|
||||
generatedVerificationCode := Strings.GenerateRandomStringWithCharset(6, "0123456789abcdef")
|
||||
kv := KV.GetInstance()
|
||||
kv.Set(constant.KVKeyEmailVerificationCode+email, generatedVerificationCode, time.Minute*10)
|
||||
return generatedVerificationCode
|
||||
}
|
||||
|
||||
func VerifyEmailCode(email, code string) bool {
|
||||
kv := KV.GetInstance()
|
||||
storedCode, ok := kv.Get(constant.KVKeyEmailVerificationCode + email)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
if storedCode != code {
|
||||
return false
|
||||
}
|
||||
kv.Delete(constant.KVKeyEmailVerificationCode + email)
|
||||
return true
|
||||
}
|
||||
|
Reference in New Issue
Block a user