예제 #1
0
파일: team.go 프로젝트: sinzone/apihub
// 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)
}
예제 #2
0
파일: app.go 프로젝트: sinzone/apihub
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
}
예제 #3
0
파일: team.go 프로젝트: sinzone/apihub
// 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
}
예제 #4
0
파일: service.go 프로젝트: sinzone/apihub
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
}