(tokenData TokenData, params url.Values, ownerId, clientId string)
| 592 | } |
| 593 | |
| 594 | func (a *Api) SetClient(tokenData TokenData, params url.Values, ownerId, clientId string) error { |
| 595 | |
| 596 | if tokenData.Owner != ownerId { |
| 597 | user, _ := a.db.GetUser(tokenData.Owner) |
| 598 | if !user.IsAdmin { |
| 599 | return errors.New("Unauthorized") |
| 600 | } |
| 601 | } |
| 602 | |
| 603 | // TODO: what if two users try to get then set at the same time? |
| 604 | owner, _ := a.db.GetUser(ownerId) |
| 605 | owner.Clients[clientId] = DbClient{} |
| 606 | a.db.SetUser(ownerId, owner) |
| 607 | |
| 608 | return nil |
| 609 | } |
| 610 | |
| 611 | func (a *Api) DeleteClient(tokenData TokenData, ownerId, clientId string) error { |
| 612 |
no test coverage detected