Update Site ID
This commit is contained in:
parent
e527872d01
commit
c41cbf91fa
@ -165,9 +165,7 @@ func (u *UserDB) ToUpdatedUser(req User) error {
|
||||
u.NIK = req.NIK
|
||||
}
|
||||
|
||||
if req.RoleID > 0 {
|
||||
u.RoleID = int64(req.RoleID)
|
||||
}
|
||||
u.RoleID = int64(req.RoleID)
|
||||
|
||||
if req.Password != "" {
|
||||
hashedPassword, err := req.HashedPassword(req.Password)
|
||||
@ -178,6 +176,9 @@ func (u *UserDB) ToUpdatedUser(req User) error {
|
||||
u.Password = hashedPassword
|
||||
}
|
||||
|
||||
u.SiteID = req.SiteID
|
||||
u.PartnerID = req.PartnerID
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -115,8 +115,10 @@ func (s *UserService) Update(ctx mycontext.Context, id int64, userReq *entity.Us
|
||||
return nil, errors.New("user not found")
|
||||
}
|
||||
|
||||
if *existingUser.PartnerID != *userReq.PartnerID {
|
||||
return nil, errors.New("user not found")
|
||||
if !ctx.IsAdmin() {
|
||||
if *existingUser.PartnerID != *userReq.PartnerID {
|
||||
return nil, errors.New("user partner cant be changed")
|
||||
}
|
||||
}
|
||||
|
||||
err = existingUser.ToUpdatedUser(*userReq)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user