MCPcopy
hub / github.com/dgraph-io/dgraph / mod

Function mod

acl/acl.go:236–267  ·  view source on GitHub ↗
(conf *viper.Viper)

Source from the content-addressed store, hash-verified

234}
235
236func 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
270func changePassword(conf *viper.Viper, userId string) error {

Callers 1

initSubcommandsFunction · 0.85

Calls 5

getUserAndGroupFunction · 0.85
checkForbiddenOptsFunction · 0.85
changePasswordFunction · 0.85
userModFunction · 0.85
chModFunction · 0.85

Tested by

no test coverage detected