v2
This commit is contained in:
@@ -2,12 +2,9 @@ package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"management/internal/db/model/dto"
|
||||
"management/internal/global/auth"
|
||||
"management/internal/pkg/session"
|
||||
systemservice "management/internal/service/system"
|
||||
)
|
||||
|
||||
@@ -61,23 +58,23 @@ func Authorize(next http.Handler) http.Handler {
|
||||
}
|
||||
|
||||
func isLogin(ctx context.Context) (*dto.AuthorizeUser, bool) {
|
||||
if exists := session.Exists(ctx, auth.StoreName); exists {
|
||||
b := session.GetBytes(ctx, auth.StoreName)
|
||||
var user dto.AuthorizeUser
|
||||
if err := json.Unmarshal(b, &user); err != nil {
|
||||
return nil, false
|
||||
}
|
||||
return &user, true
|
||||
}
|
||||
// if exists := session.Exists(ctx, auth.StoreName); exists {
|
||||
// b := session.GetBytes(ctx, auth.StoreName)
|
||||
// var user dto.AuthorizeUser
|
||||
// if err := json.Unmarshal(b, &user); err != nil {
|
||||
// return nil, false
|
||||
// }
|
||||
// return &user, true
|
||||
// }
|
||||
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func AuthUser(ctx context.Context) dto.AuthorizeUser {
|
||||
var user dto.AuthorizeUser
|
||||
if exists := session.Exists(ctx, auth.StoreName); exists {
|
||||
b := session.GetBytes(ctx, auth.StoreName)
|
||||
_ = json.Unmarshal(b, &user)
|
||||
}
|
||||
// if exists := session.Exists(ctx, auth.StoreName); exists {
|
||||
// b := session.GetBytes(ctx, auth.StoreName)
|
||||
// _ = json.Unmarshal(b, &user)
|
||||
// }
|
||||
return user
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user