示例#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
}