This repository has been archived by the owner on Jul 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MM-29523] New flag for user creation command (#257)
* New flag for user creation command This new flag will mark the user email as verified without having too do it after the creation
- Loading branch information
Showing
20 changed files
with
342 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,11 +43,21 @@ var UserDeactivateCmd = &cobra.Command{ | |
} | ||
|
||
var UserCreateCmd = &cobra.Command{ | ||
Use: "create", | ||
Short: "Create a user", | ||
Long: "Create a user", | ||
Example: ` user create --email [email protected] --username userexample --password Password1`, | ||
RunE: withClient(userCreateCmdF), | ||
Use: "create", | ||
Short: "Create a user", | ||
Long: "Create a user", | ||
Example: ` # You can create a user | ||
$ mmctl user create --email [email protected] --username userexample --password Password1 | ||
# You can define optional fields like first name, last name and nick name too | ||
$ mmctl user create --email [email protected] --username userexample --password Password1 --firstname User --lastname Example --nickname userex | ||
# Also you can create the user as system administrator | ||
$ mmctl user create --email [email protected] --username userexample --password Password1 --system-admin | ||
# Finally you can verify user on creation if you have enough permissions | ||
$ mmctl user create --email [email protected] --username userexample --password Password1 --system-admin --email-verified`, | ||
RunE: withClient(userCreateCmdF), | ||
} | ||
|
||
var UserInviteCmd = &cobra.Command{ | ||
|
@@ -221,6 +231,7 @@ func init() { | |
UserCreateCmd.Flags().String("lastname", "", "Optional. The last name for the new user account") | ||
UserCreateCmd.Flags().String("locale", "", "Optional. The locale (ex: en, fr) for the new user account") | ||
UserCreateCmd.Flags().Bool("system_admin", false, "Optional. If supplied, the new user will be a system administrator. Defaults to false") | ||
UserCreateCmd.Flags().Bool("email_verified", false, "Optional. If supplied, the new user will have the email verified. Defaults to false") | ||
|
||
DeleteUsersCmd.Flags().Bool("confirm", false, "Confirm you really want to delete the user and a DB backup has been performed") | ||
DeleteAllUsersCmd.Flags().Bool("confirm", false, "Confirm you really want to delete the user and a DB backup has been performed") | ||
|
@@ -364,15 +375,17 @@ func userCreateCmdF(c client.Client, cmd *cobra.Command, args []string) error { | |
lastname, _ := cmd.Flags().GetString("lastname") | ||
locale, _ := cmd.Flags().GetString("locale") | ||
systemAdmin, _ := cmd.Flags().GetBool("system_admin") | ||
emailVerified, _ := cmd.Flags().GetBool("email_verified") | ||
|
||
user := &model.User{ | ||
Username: username, | ||
Email: email, | ||
Password: password, | ||
Nickname: nickname, | ||
FirstName: firstname, | ||
LastName: lastname, | ||
Locale: locale, | ||
Username: username, | ||
Email: email, | ||
Password: password, | ||
Nickname: nickname, | ||
FirstName: firstname, | ||
LastName: lastname, | ||
Locale: locale, | ||
EmailVerified: emailVerified, | ||
} | ||
|
||
ruser, response := c.CreateUser(user) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,14 +20,25 @@ Examples | |
|
||
:: | ||
|
||
user create --email [email protected] --username userexample --password Password1 | ||
# You can create a user | ||
$ mmctl user create --email [email protected] --username userexample --password Password1 | ||
|
||
# You can define optional fields like first name, last name and nick name too | ||
$ mmctl user create --email [email protected] --username userexample --password Password1 --firstname User --lastname Example --nickname userex | ||
|
||
# Also you can create the user as system administrator | ||
$ mmctl user create --email [email protected] --username userexample --password Password1 --system-admin | ||
|
||
# Finally you can verify user on creation if you have enough permissions | ||
$ mmctl user create --email [email protected] --username userexample --password Password1 --system-admin --email-verified | ||
|
||
Options | ||
~~~~~~~ | ||
|
||
:: | ||
|
||
--email string Required. The email address for the new user account | ||
--email_verified Optional. If supplied, the new user will have the email verified. Defaults to false | ||
--firstname string Optional. The first name for the new user account | ||
-h, --help help for create | ||
--lastname string Optional. The last name for the new user account | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
vendor/github.com/mattermost/mattermost-server/v5/api4/cloud.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
vendor/github.com/mattermost/mattermost-server/v5/api4/user.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
vendor/github.com/mattermost/mattermost-server/v5/app/app_iface.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
vendor/github.com/mattermost/mattermost-server/v5/app/cloud.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
vendor/github.com/mattermost/mattermost-server/v5/app/email.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.