Skip to content

replyUpdateUser computes the missing-credentials list only when GetAllCreds failed #1011

Description

@akiva1132

In replyUpdateUser (server/user.go, master at the time of writing):

if allCreds, err := store.Users.GetAllCreds(uid, "", true); err != nil {
	var validated []string
	for i := range allCreds {
		validated = append(validated, allCreds[i].Method)
	}
	_, missing, _ := stringSliceDelta(globals.authValidators[authLvl], validated)
	if len(missing) > 0 {
		params = map[string]any{"cred": missing}
	}
}

The condition is err != nil, so the body — which builds the list of credentials the account still lacks — runs only when GetAllCreds failed, and then over an empty allCreds. On the path that works nothing runs, params stays nil, and the {ctrl} answering a successful {acc cred:[...]} never carries cred.

Expected: err == nil, so the reply tells the client which required validators are still unconfirmed (the same list replyCreateUser returns after registration).

Reproduced with a unit test around Session.dispatch using the gomock store: with one validated tel credential and auth_validators requiring tel and email, the reply's params.cred is nil; with the condition flipped it is ["email"].

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions