Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Reset password, state layer. #7740
Conversation
| @@ -543,6 +540,61 @@ func (u *User) ensureNotDeleted() error { | ||
| return nil | ||
| } | ||
| +// ResetPassword cleans up password related field. |
axw
Aug 15, 2017
Member
ResetPassword clears the user's password (if there is one), and generates a new secret key for the user.
?
| + return nil, errors.Trace(err) | ||
| + } | ||
| + if u.IsDisabled() { | ||
| + return nil, fmt.Errorf("user deactivated") |
axw
Aug 15, 2017
Member
cannot reset password for disabled user?
or maybe add a DeferredAnnotate at the top of the function instead
anastasiamac
Aug 15, 2017
Member
I am not convinced that this needs further clarification. The overall error that will come from here will be cannot reset password for user "bob": user deactivated.
| + if err := u.st.db().Run(buildTxn); err != nil { | ||
| + return nil, errors.Annotatef(err, "cannot reset password for user %q", u.Name()) | ||
| + } | ||
| + u.doc.SecretKey = key |
| + return key, nil | ||
| +} | ||
| + | ||
| +// generateSecretKey generates a random, 32-byte secret key. This can be used |
axw
Aug 15, 2017
Member
can you you please delete the bit about the CA cert? we're not using it for that. not sure why it was in there before, probably copy pasta
| + | ||
| + key, err := u.ResetPassword() | ||
| + c.Assert(err, jc.ErrorIsNil) | ||
| + c.Assert(u.SecretKey(), gc.DeepEquals, key) |
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju |
jujubot
merged commit a801c19
into
juju:develop
Aug 15, 2017
1 check passed
continuous-integration/jenkins/pr-merge
This commit looks good
Details
anastasiamac
deleted the
anastasiamac:reset-pwd-state
branch
Aug 15, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
anastasiamac commentedAug 14, 2017
Description of change
This is part of the functionality to provide controller admins with ability to reset user passwords/re-issue login tokens.
QA steps
This is only one the layers, there is no full-stack funcationaliy yet. All unit tests pass.
Documentation changes
n/a
This is an internal addition atm.
Bug reference
Initial part for https://bugs.launchpad.net/juju/+bug/1657187