CheckAuth checks if the user is authenticated.
(ch *Helper)
| 23 | |
| 24 | // CheckAuth checks if the user is authenticated. |
| 25 | func CheckAuth(ch *Helper) PreRunCheck { |
| 26 | return func(cmd *cobra.Command, args []string) error { |
| 27 | localFlag := cmd.Flags().Lookup("local") |
| 28 | if localFlag != nil && localFlag.Changed { |
| 29 | return nil |
| 30 | } |
| 31 | |
| 32 | // This will just check if token is present in the config |
| 33 | if !ch.IsAuthenticated() { |
| 34 | return fmt.Errorf("not authenticated, please run 'rill login'") |
| 35 | } |
| 36 | return nil |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | // CheckOrganization checks if the user has an organization set. |
| 41 | func CheckOrganization(ch *Helper) PreRunCheck { |
no test coverage detected