edit check token supplier user

This commit is contained in:
buiphuan0211 2022-12-29 13:49:04 +07:00
parent ec9dedad0d
commit 4fd0a89acd
8 changed files with 41 additions and 35 deletions

View File

@ -178,23 +178,3 @@ func (s Supplier) UpdateWarehouseIntoServiceSupplier(p model.UpdateSupplierWareh
}
return nil
}
// CheckTokenSupplier ...
func (s Supplier) CheckTokenSupplier(p model.CheckTokenSupplierPayload) (*model.ResponseCheckTokenSupplier, error) {
msg, err := natsio.GetServer().Request(subject.Supplier.CheckTokenSupplier, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Error string `json:"error"`
Data *model.ResponseCheckTokenSupplier `json:"data"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return nil, err
}
if r.Error != "" {
return nil, errors.New(r.Error)
}
return r.Data, nil
}

View File

@ -138,3 +138,23 @@ func (s SupplierUser) ResetPassword(p model.ResetPasswordRequest) (*model.ResetP
return r.Data, nil
}
// CheckTokenSupplier ...
func (s SupplierUser) CheckTokenSupplier(p model.CheckTokenSupplierUserPayload) (*model.ResponseCheckTokenSupplierUser, error) {
msg, err := natsio.GetServer().Request(subject.SupplierUser.CheckToken, toBytes(p))
if err != nil {
return nil, err
}
var r struct {
Error string `json:"error"`
Data *model.ResponseCheckTokenSupplierUser `json:"data"`
}
if err = json.Unmarshal(msg.Data, &r); err != nil {
return nil, err
}
if r.Error != "" {
return nil, errors.New(r.Error)
}
return r.Data, nil
}

View File

@ -52,9 +52,3 @@ type SupplierCountReq struct {
IDs []string `json:"ids"`
Status string `json:"status"` // active,inactive
}
// CheckTokenSupplierPayload ...
type CheckTokenSupplierPayload struct {
Token string `json:"token"`
Permissions []string `json:"permissions"`
}

View File

@ -33,10 +33,3 @@ type SupplierAll struct {
type SupplierCountRes struct {
Total int64 `json:"total"`
}
// ResponseCheckTokenSupplier ...
type ResponseCheckTokenSupplier struct {
IsValid bool `json:"isValid"`
Reason string `json:"reason"`
Supplier ResponseSupplierInfo `json:"supplier"`
}

View File

@ -49,3 +49,9 @@ type ResetPasswordRequest struct {
ID string `json:"_id"`
Password string `json:"password"`
}
// CheckTokenSupplierUserPayload ...
type CheckTokenSupplierUserPayload struct {
Token string `json:"token"`
Permissions []string `json:"permissions"`
}

View File

@ -11,3 +11,16 @@ type CreateStaffResponse struct {
type ResetPasswordResponse struct {
Password string `json:"password"`
}
// ResponseCheckTokenSupplierUser ...
type ResponseCheckTokenSupplierUser struct {
IsValid bool `json:"isValid"`
Reason string `json:"reason"`
User ResponseSupplierUserInfo `json:"supplier"`
}
type ResponseSupplierUserInfo struct {
ID string `json:"_id"`
Name string `json:"name"`
SupplierID string `json:"supplierId"`
}

View File

@ -12,12 +12,10 @@ var Supplier = struct {
FindAll string
FindAllOld string
Count string
CheckTokenSupplier string
}{
GetListSupplierInfo: getSupplierValue("get_list_supplier_info"),
GetSupplierContractBySupplierID: getSupplierValue("get_supplier_contract_by_supplier_id"),
FindAll: getSupplierValue("find_all"),
FindAllOld: getSupplierValue("find_all_old"),
Count: getSupplierValue("count"),
CheckTokenSupplier: getSupplierValue("check_token_supplier"),
}

View File

@ -14,6 +14,7 @@ var SupplierUser = struct {
UpdateStaff string
UpdateStatus string
ResetPassword string
CheckToken string
}{
// Users
CreateOwner: getSupplierUserValue("create_owner"),
@ -22,4 +23,5 @@ var SupplierUser = struct {
UpdateStaff: getSupplierUserValue("update_staff"),
UpdateStatus: getSupplierUserValue("update_status"),
ResetPassword: getSupplierUserValue("reset_password"),
CheckToken: getSupplierUserValue("check_token"),
}