Beispiel #1
0
// Check if the user belongs to the team.
// Return the position if so.
func (team *Team) ContainsUser(user *User) (int, error) {
	for i, u := range team.Users {
		if u == user.Email {
			return i, nil
		}
	}
	return -1, errors.NewForbiddenError(errors.ErrUserNotInTeam)
}
Beispiel #2
0
func (app App) Delete(owner User) error {
	if app.Owner != owner.Email {
		Logger.Info("Failed to delete an app. Only the owner has permission to do that: %+v.", app)
		return errors.NewForbiddenError(errors.ErrOnlyOwnerHasPermission)
	}

	err := store.DeleteApp(app)
	Logger.Info("app.Delete: %+v. Err: %s.", app, err)
	return err
}
Beispiel #3
0
// Delete removes an existing team from the server.
func (team Team) Delete(owner User) error {
	if team.Owner != owner.Email {
		return errors.NewForbiddenError(errors.ErrOnlyOwnerHasPermission)
	}

	go DeleteServicesByTeam(team, owner)
	go DeleteAppsByTeam(team, owner)
	go store.DeleteHooksByTeam(team)

	err := store.DeleteTeam(team)
	Logger.Info("team.Delete: %+v. Err: %s.", team, err)
	return err
}
Beispiel #4
0
func (service *Service) Delete(owner User) error {
	if service.Owner != owner.Email {
		Logger.Warn("Only the owner has permission to delete the following service: %s.", service.Subdomain)
		return errors.NewForbiddenError(errors.ErrOnlyOwnerHasPermission)
	}

	go store.DeletePluginsByService(*service)

	err := store.DeleteService(*service)
	if err == nil {
		service.Disabled = true
		go publishService(service)
	}
	Logger.Info("service.Delete: %+v. Err: %s.", service, err)
	return err
}