From 4ae83b7cc84f59f08311e2107aa9ef4a84d7fba7 Mon Sep 17 00:00:00 2001 From: vishalnayak Date: Wed, 16 Mar 2016 14:53:53 -0400 Subject: [PATCH] Add comments to existence functions --- builtin/credential/userpass/path_login.go | 5 +---- builtin/credential/userpass/path_user_password.go | 2 ++ builtin/credential/userpass/path_user_policies.go | 2 ++ builtin/credential/userpass/path_users.go | 1 - 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/builtin/credential/userpass/path_login.go b/builtin/credential/userpass/path_login.go index 28ef665fbbd6..458d35e8bb98 100644 --- a/builtin/credential/userpass/path_login.go +++ b/builtin/credential/userpass/path_login.go @@ -37,9 +37,6 @@ func pathLogin(b *backend) *framework.Path { func (b *backend) pathLogin( req *logical.Request, d *framework.FieldData) (*logical.Response, error) { username := strings.ToLower(d.Get("username").(string)) - if username == "" { - return nil, fmt.Errorf("missing username") - } password := d.Get("password").(string) if password == "" { @@ -52,7 +49,7 @@ func (b *backend) pathLogin( return nil, err } if user == nil { - return logical.ErrorResponse("unknown username or password"), nil + return logical.ErrorResponse("username does not exist"), nil } // Check for a password match. Check for a hash collision for Vault 0.2+, diff --git a/builtin/credential/userpass/path_user_password.go b/builtin/credential/userpass/path_user_password.go index bc599f28375c..22c08239a800 100644 --- a/builtin/credential/userpass/path_user_password.go +++ b/builtin/credential/userpass/path_user_password.go @@ -35,6 +35,8 @@ func pathUserPassword(b *backend) *framework.Path { } } +// By always returning true, this endpoint will be enforced to be invoked only upon UpdateOperation. +// The existence of user will be checked in the operation handler. func (b *backend) userPasswordExistenceCheck(req *logical.Request, data *framework.FieldData) (bool, error) { return true, nil } diff --git a/builtin/credential/userpass/path_user_policies.go b/builtin/credential/userpass/path_user_policies.go index 217646fca532..73b9fe6d6a2f 100644 --- a/builtin/credential/userpass/path_user_policies.go +++ b/builtin/credential/userpass/path_user_policies.go @@ -33,6 +33,8 @@ func pathUserPolicies(b *backend) *framework.Path { } } +// By always returning true, this endpoint will be enforced to be invoked only upon UpdateOperation. +// The existence of user will be checked in the operation handler. func (b *backend) userPoliciesExistenceCheck(req *logical.Request, data *framework.FieldData) (bool, error) { return true, nil } diff --git a/builtin/credential/userpass/path_users.go b/builtin/credential/userpass/path_users.go index a9bbaef21178..21fe4162559a 100644 --- a/builtin/credential/userpass/path_users.go +++ b/builtin/credential/userpass/path_users.go @@ -130,7 +130,6 @@ func (b *backend) userCreateUpdate(req *logical.Request, d *framework.FieldData) userEntry = &UserEntry{} } - // "password" will always be set here if _, ok := d.GetOk("password"); ok { err = b.updateUserPassword(req, d, userEntry) if err != nil {