fix version 1
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
// 获取邮件服务器配置
|
||||
func GetEmail(ctx context.Context, in *pb.IdentRequest) (reply *pb.ConfigsReply, err error) {
|
||||
_, err = service.ParseMetaCtx(ctx, nil)
|
||||
auth, err := service.ParseMetaCtx(ctx, &service.ParseOptions{RoleValue: "Mall_Admin"})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -21,11 +21,21 @@ func GetEmail(ctx context.Context, in *pb.IdentRequest) (reply *pb.ConfigsReply,
|
||||
return nil, errcode.ErrInvalidArgument
|
||||
}
|
||||
|
||||
// 只能读取当前登录者所属店铺的配置
|
||||
owner, _ := auth.Owner.(map[string]any)
|
||||
storeIdentity, _ := owner["store_identity"].(string)
|
||||
|
||||
sotre := models.MallStore{}
|
||||
if err := impl.DBService.Model(&models.MallStore{}).Select("mail_configs").Where("id=? or identity=?", in.GetId(), in.GetIdentity()).Find(&sotre).Error; err != nil {
|
||||
print(err.Error())
|
||||
tx := impl.DBService.Model(&models.MallStore{}).Select("mail_configs").
|
||||
Where("id=? or identity=?", in.GetId(), in.GetIdentity()).
|
||||
Where("identity = ?", storeIdentity).Find(&sotre)
|
||||
if tx.Error != nil {
|
||||
print(tx.Error.Error())
|
||||
return nil, errcode.ErrDB
|
||||
}
|
||||
if storeIdentity == "" || tx.RowsAffected == 0 {
|
||||
return nil, errcode.ErrPermissionDenied
|
||||
}
|
||||
|
||||
return &pb.ConfigsReply{
|
||||
Configs: sotre.MailConfigs,
|
||||
|
||||
Reference in New Issue
Block a user