feat (encounter): create and checkout + checking soapi done
This commit is contained in:
No files matched your search
@@ -16,10 +16,11 @@ import (
|
||||
a "github.com/karincake/apem"
|
||||
ms "github.com/karincake/apem/ms-redis"
|
||||
|
||||
pa "simrs-vx/pkg/auth-helper"
|
||||
el "simrs-vx/pkg/logger"
|
||||
p "simrs-vx/pkg/password"
|
||||
|
||||
mu "simrs-vx/internal/domain/main-entities/user"
|
||||
eu "simrs-vx/internal/domain/main-entities/user"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
)
|
||||
|
||||
@@ -31,9 +32,9 @@ func init() {
|
||||
|
||||
// Generates token and store in redis at one place
|
||||
// just return the error code
|
||||
func GenToken(input mu.LoginDto) (*d.Data, error) {
|
||||
func GenToken(input eu.LoginDto) (*d.Data, error) {
|
||||
// Get User
|
||||
user := &mu.User{Name: input.Name}
|
||||
user := &eu.User{Name: input.Name}
|
||||
// if input.Position_Code != "" {
|
||||
// user.Position_Code = input.Position_Code
|
||||
// }
|
||||
@@ -94,7 +95,7 @@ func GenToken(input mu.LoginDto) (*d.Data, error) {
|
||||
atClaims["user_id"] = user.Id
|
||||
atClaims["user_name"] = user.Name
|
||||
// atClaims["user_email"] = user.Email
|
||||
// atClaims["user_position_code"] = user.Position_Code
|
||||
atClaims["user_position_code"] = user.Position_Code
|
||||
// atClaims["user_ref_id"] = user.Ref_Id
|
||||
atClaims["exp"] = atExpires
|
||||
atClaims["uuid"] = aUuid
|
||||
@@ -129,7 +130,7 @@ func GenToken(input mu.LoginDto) (*d.Data, error) {
|
||||
"user_id": strconv.Itoa(int(user.Id)),
|
||||
"user_name": user.Name,
|
||||
// "user_email": user.Email,
|
||||
// "user_position_code": user.Position_Code,
|
||||
"user_position_code": user.Position_Code,
|
||||
// "user_ref_id": user.Ref_Id,
|
||||
"accessToken": ats,
|
||||
},
|
||||
@@ -167,7 +168,7 @@ func VerifyToken(r *http.Request, tokenType TokenType) (data *jwt.Token, errCode
|
||||
return token, "", ""
|
||||
}
|
||||
|
||||
func ExtractToken(r *http.Request, tokenType TokenType) (data *AuthInfo, err error) {
|
||||
func ExtractToken(r *http.Request, tokenType TokenType) (data *pa.AuthInfo, err error) {
|
||||
token, errCode, errDetail := VerifyToken(r, tokenType)
|
||||
if errCode != "" {
|
||||
return nil, d.FieldError{Code: errCode, Message: el.GenMessage(errCode, errDetail)}
|
||||
@@ -196,17 +197,17 @@ func ExtractToken(r *http.Request, tokenType TokenType) (data *AuthInfo, err err
|
||||
// tmp := v.(float64)
|
||||
// ref_id = int(tmp)
|
||||
// }
|
||||
// position_code := ""
|
||||
// if v, exist := claims["user_position_code"]; exist && v != nil {
|
||||
// position_code = v.(string)
|
||||
// }
|
||||
data = &AuthInfo{
|
||||
position_code := ""
|
||||
if v, exist := claims["user_position_code"]; exist && v != nil {
|
||||
position_code = v.(string)
|
||||
}
|
||||
data = &pa.AuthInfo{
|
||||
Uuid: accessUuid,
|
||||
User_Id: int(user_id),
|
||||
User_Id: uint(user_id),
|
||||
User_Name: user_name,
|
||||
// User_Email: user_email,
|
||||
// User_Ref_Id: ref_id,
|
||||
// User_Position_Code: position_code,
|
||||
User_Position_Code: position_code,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5,15 +5,6 @@ type TokenType string
|
||||
const AccessToken = "Access"
|
||||
const RefreshToken = "Refresh"
|
||||
|
||||
type AuthInfo struct {
|
||||
Uuid string
|
||||
User_Id int
|
||||
User_Name string
|
||||
// User_Email string
|
||||
// User_Ref_Id int
|
||||
// User_Position_Code string
|
||||
}
|
||||
|
||||
type AuthCfg struct {
|
||||
AtSecretKey string `yaml:"atSecretKey"`
|
||||
RtSecretKey string `yaml:"rtSecretKey"`
|
||||
|
||||
Reference in New Issue
Block a user