diff --git a/README.md b/README.md index 8e21c3a..78904ca 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,6 @@ func main() { client := taiga.Client{ BaseURL: "https://api.taiga.io", HTTPClient: &http.Client{}, - LoginType: "normal", } // Initialise client (authenticates to Taiga) diff --git a/client.go b/client.go index 113cc78..9d536be 100644 --- a/client.go +++ b/client.go @@ -15,7 +15,6 @@ type Client struct { BaseURL string // i.e.: "http://taiga.test" | Same value as `api` in `taiga-front-dist/dist/conf.json` Headers *http.Header // mostly set by system HTTPClient *http.Client // set by user - LoginType string // i.e.: "normal"; "github"; "ldap" Token string // set by system; can be set manually TokenType string // default=Bearer; options:Bearer,Application Self *User // User logged in @@ -105,9 +104,6 @@ func (c *Client) Initialise() error { return fmt.Errorf("BaseURL is not set or invalid") } - if len(c.LoginType) <= 1 { - return fmt.Errorf("LoginType is not set") - } //Set basic token type if len(c.TokenType) <= 1 { c.TokenType = "Bearer" @@ -152,10 +148,16 @@ func (c *Client) AuthByCredentials(credentials *Credentials) error { if !c.isInitialised { return fmt.Errorf("Client not initialised") } + + if len(credentials.Type) <= 1 { + return fmt.Errorf("LoginType is not set") + } + user, err := c.Auth.login(credentials) if err != nil { return err } + c.Self = user.AsUser() return nil } diff --git a/examples/README.MD b/examples/README.MD index a8e1155..a3a330b 100644 --- a/examples/README.MD +++ b/examples/README.MD @@ -26,7 +26,6 @@ func main() { client := taiga.Client{ BaseURL: "https://api.taiga.io", HTTPClient: &http.Client{}, - LoginType: "normal", } // Initialise client (authenticates to Taiga) err := client.Initialise()