Example #1
0
func (s *S) TestDeleteAppsByTeam(c *C) {
	app.Create(alice, team)
	c.Assert(app.Exists(), Equals, true)

	newApp := account.App{ClientId: "android", ClientSecret: "secret", Name: "Andoird App", Team: team.Alias, Owner: owner.Email, RedirectUris: []string{"http://www.example.org/auth"}}
	newApp.Create(alice, team)

	account.DeleteAppsByTeam(team, alice)

	_, err := account.FindAppByClientId("ios")
	c.Check(err, Not(IsNil))
	_, err = account.FindAppByClientId("android")
	c.Check(err, Not(IsNil))
}
Example #2
0
func (api *Api) appCreate(rw http.ResponseWriter, r *http.Request, user *account.User) {
	app := account.App{}
	if err := json.NewDecoder(r.Body).Decode(&app); err != nil {
		handleError(rw, errors.ErrBadRequest)
		return
	}

	team, err := findTeamAndCheckUser(app.Team, user)
	if err != nil {
		handleError(rw, err)
		return
	}

	if err := app.Create(*user, *team); err != nil {
		handleError(rw, err)
		return
	}

	Created(rw, app)
}