1+ // Package auth handles user management: creation, deletion, and authentication.
12package auth
23
34import (
@@ -10,6 +11,8 @@ import (
1011)
1112
1213// Register a new user with the controller.
14+ // If controller registration is set to administratiors only, a valid administrative
15+ // user token is required in the client.
1316func Register (c * deis.Client , username , password , email string ) error {
1417 user := api.AuthRegisterRequest {Username : username , Password : password , Email : email }
1518 body , err := json .Marshal (user )
@@ -73,7 +76,17 @@ func Delete(c *deis.Client, username string) error {
7376 return err
7477}
7578
76- // Regenerate user's auth tokens.
79+ // Regenerate auth tokens. This invalidates existing tokens, and if targeting a specific user
80+ // returns a new token.
81+ //
82+ // If username is an empty string and all is false, this regenerates the
83+ // client user's token and will return a new token. Make sure to update the client token
84+ // with this new token to avoid authentication errors.
85+ //
86+ // If username is set and all is false, this will regenerate that user's token
87+ // and return a new token. If not targeting yourself, regenerate requires administrative privilages.
88+ //
89+ // If all is true, this will regenerate every user's token. This requires administrative privilages.
7790func Regenerate (c * deis.Client , username string , all bool ) (string , error ) {
7891 var reqBody []byte
7992 var err error
@@ -111,6 +124,11 @@ func Regenerate(c *deis.Client, username string, all bool) (string, error) {
111124}
112125
113126// Passwd changes a user's password.
127+ //
128+ // If username if an empty string, change the password of the client's user.
129+ //
130+ // If username is set, change the password of another user and do not require
131+ // their password. This requires administrative privilages.
114132func Passwd (c * deis.Client , username , password , newPassword string ) error {
115133 req := api.AuthPasswdRequest {Password : password , NewPassword : newPassword }
116134
0 commit comments