github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/actor/sharedaction/auth.go (about)

     1  package sharedaction
     2  
     3  type DefaultAuthActor struct {
     4  	config Config
     5  }
     6  
     7  func NewDefaultAuthActor(config Config) DefaultAuthActor {
     8  	return DefaultAuthActor{
     9  		config: config,
    10  	}
    11  }
    12  
    13  func (a DefaultAuthActor) IsLoggedIn() bool {
    14  	return a.config.AccessToken() != "" || a.config.RefreshToken() != ""
    15  }
    16  
    17  type K8sAuthActor struct {
    18  	config Config
    19  }
    20  
    21  func NewK8sAuthActor(config Config) K8sAuthActor {
    22  	return K8sAuthActor{
    23  		config: config,
    24  	}
    25  }
    26  
    27  func (a K8sAuthActor) IsLoggedIn() bool {
    28  	name, err := a.config.CurrentUserName()
    29  
    30  	return err == nil && name != ""
    31  }