Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Userpass: Update the password and policies associated to user #1216

Merged
merged 15 commits into from Mar 16, 2016

Conversation

vishalnayak
Copy link
Member

No description provided.

@@ -109,6 +109,98 @@ func TestBackend_userCrud(t *testing.T) {
})
}

func TestBacken_userCreateOperation(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestBacken -> TestBackend

return false, fmt.Errorf("missing username")
}

entry, err := req.Storage.Get("user/" + strings.ToLower(username))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use the same logic here that you're using in userCreateUpdate, just to be safe in case something diverges. So that probably means using b.user() here.

return false, fmt.Errorf("missing username")
}

userEntry, err := b.user(req.Storage, username)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If username is always the name of the value, you can simply pass in data to b.user and have it return an error if there is a missing username. This lets you remove this check in a few other places too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this is called in pathLoginRenew. Even so, you can pass data.Get("username").(string) directly in and check if it's empty in b.user

}
}

func (b *backend) userPasswordExistenceCheck(req *logical.Request, data *framework.FieldData) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks much better -- please do add a comment though explaining why this existence check always returns true.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(For future code-browsers to avoid scratching heads.)

vishalnayak added a commit that referenced this pull request Mar 16, 2016
Userpass: Update the password and policies associated to user
@vishalnayak vishalnayak merged commit b9b4f45 into master Mar 16, 2016
@vishalnayak vishalnayak deleted the userpass-update branch March 16, 2016 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants