(conf *viper.Viper)
| 234 | } |
| 235 | |
| 236 | func mod(conf *viper.Viper) error { |
| 237 | userId, _, err := getUserAndGroup(conf) |
| 238 | if err != nil { |
| 239 | return err |
| 240 | } |
| 241 | |
| 242 | if len(userId) != 0 { |
| 243 | // when modifying the user, some group options are forbidden |
| 244 | if err := checkForbiddenOpts(conf, []string{"pred", "perm"}); err != nil { |
| 245 | return err |
| 246 | } |
| 247 | |
| 248 | newPassword := conf.GetBool("new_password") |
| 249 | groupList := conf.GetString("group_list") |
| 250 | if (newPassword && groupList != defaultGroupList) || |
| 251 | (!newPassword && groupList == defaultGroupList) { |
| 252 | return errors.New("one of --new_password or --group_list must be provided, but not both") |
| 253 | } |
| 254 | |
| 255 | if newPassword { |
| 256 | return changePassword(conf, userId) |
| 257 | } |
| 258 | |
| 259 | return userMod(conf, userId, groupList) |
| 260 | } |
| 261 | |
| 262 | // when modifying the group, some user options are forbidden |
| 263 | if err := checkForbiddenOpts(conf, []string{"group_list", "new_password"}); err != nil { |
| 264 | return err |
| 265 | } |
| 266 | return chMod(conf) |
| 267 | } |
| 268 | |
| 269 | // changePassword changes a user's password |
| 270 | func changePassword(conf *viper.Viper, userId string) error { |
no test coverage detected