github.com/decred/politeia@v1.4.0/politeiawww/cmd/cmswww/invitenewuser.go (about) 1 // Copyright (c) 2017-2019 The Decred developers 2 // Use of this source code is governed by an ISC 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 "fmt" 9 10 v1 "github.com/decred/politeia/politeiawww/api/cms/v1" 11 "github.com/decred/politeia/politeiawww/cmd/shared" 12 ) 13 14 // InviteNewUserCmd allows administrators to invite contractors to join CMS. 15 type InviteNewUserCmd struct { 16 Args struct { 17 Email string `positional-arg-name:"email" ` 18 } `positional-args:"true"` 19 Temporary bool `long:"temp" optional:"true"` 20 } 21 22 // Execute executes the invite new user command. 23 func (cmd *InviteNewUserCmd) Execute(args []string) error { 24 inu := &v1.InviteNewUser{ 25 Email: cmd.Args.Email, 26 Temporary: cmd.Temporary, 27 } 28 29 // Print request details 30 err := shared.PrintJSON(inu) 31 if err != nil { 32 return err 33 } 34 35 // Send request 36 inur, err := client.InviteNewUser(inu) 37 if err != nil { 38 return fmt.Errorf("InviteNewUser: %v", err) 39 } 40 41 // Print response details 42 err = shared.PrintJSON(inur) 43 if err != nil { 44 return err 45 } 46 47 return nil 48 } 49 50 const inviteNewUserHelpMsg = `invite "email" 51 52 Send a new user invitation to the given email. 53 54 If email has been disabled on the politeiawww server then the verification 55 token that would normally be sent to the email address will be returned in the 56 response. 57 58 Arguments: 59 1. email (string, required) Email address 60 61 Flags: 62 --temp (bool, optional) Designate the user as a temporary user. This 63 means the user will only be able to submit a 64 single invoice before being deactivated. 65 `