github.com/decred/politeia@v1.4.0/politeiawww/cmd/shared/logout.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 shared 6 7 import "fmt" 8 9 // LogoutCmd logs the user out of Politeia. 10 type LogoutCmd struct{} 11 12 // Execute executes the logout command. 13 func (cmd *LogoutCmd) Execute(args []string) error { 14 lr, err := client.Logout() 15 if err != nil { 16 return err 17 } 18 19 // Update the logged in username that we store on disk 20 err = cfg.SaveLoggedInUsername("") 21 if err != nil { 22 return fmt.Errorf("SaveLoggedInUsername: %v", err) 23 } 24 25 return PrintJSON(lr) 26 } 27 28 // LogoutHelpMsg is the output of the help command when 'logout' is specified. 29 const LogoutHelpMsg = `logout 30 31 Logout as a user or admin. 32 33 Arguments: 34 None`