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,33 +1,32 @@
|
||||
package ctxutils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"context"
|
||||
|
||||
"github.com/snowykami/neo-blog/internal/model"
|
||||
"github.com/snowykami/neo-blog/internal/repo"
|
||||
"github.com/snowykami/neo-blog/pkg/constant"
|
||||
"github.com/snowykami/neo-blog/internal/model"
|
||||
"github.com/snowykami/neo-blog/internal/repo"
|
||||
"github.com/snowykami/neo-blog/pkg/constant"
|
||||
)
|
||||
|
||||
// GetCurrentUser 从上下文中获取当前用户
|
||||
func GetCurrentUser(ctx context.Context) (*model.User, bool) {
|
||||
val := ctx.Value(constant.ContextKeyUserID)
|
||||
if val == nil {
|
||||
return nil, false
|
||||
}
|
||||
user, err := repo.User.GetUserByID(val.(uint))
|
||||
if err != nil {
|
||||
return nil, false
|
||||
}
|
||||
val := ctx.Value(constant.ContextKeyUserID)
|
||||
if val == nil {
|
||||
return nil, false
|
||||
}
|
||||
user, err := repo.User.GetUserByID(val.(uint))
|
||||
if err != nil {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
return user, true
|
||||
return user, true
|
||||
}
|
||||
|
||||
// GetCurrentUserID 从上下文中获取当前用户ID
|
||||
func GetCurrentUserID(ctx context.Context) (uint, bool) {
|
||||
user, ok := GetCurrentUser(ctx)
|
||||
if !ok || user == nil {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
return user.ID, true
|
||||
user, ok := GetCurrentUser(ctx)
|
||||
if !ok || user == nil {
|
||||
return 0, false
|
||||
}
|
||||
return user.ID, true
|
||||
}
|
||||
|
Reference in New Issue
Block a user