9 func (c *Client) Login(name, password string) error {
11 if err := c.init(); err != nil {
16 params := map[string]interface{}{
17 "username_or_email": name,
20 resp, err := c.post("/user/login", params)
24 defer resp.Body.Close()
25 if resp.StatusCode != http.StatusOK {
26 return fmt.Errorf("remote status %s: %w", resp.Status, decodeError(resp.Body))
32 if err := json.NewDecoder(resp.Body).Decode(&response); err != nil {
33 return fmt.Errorf("decode login response: %w", err)
35 c.authToken = response.JWT
39 func (c *Client) Authenticated() bool {
40 return c.authToken != ""