func revokeAppAccess(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	appName := r.URL.Query().Get(":app")
	teamName := r.URL.Query().Get(":team")
	a, err := getAppFromContext(appName, r)
	if err != nil {
		return err
	}
	allowed := permission.Check(t, permission.PermAppUpdateRevoke,
		contextsForApp(&a)...,
	)
	if !allowed {
		return permission.ErrUnauthorized
	}
	evt, err := event.New(&event.Opts{
		Target:     appTarget(appName),
		Kind:       permission.PermAppUpdateRevoke,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermAppReadEvents, contextsForApp(&a)...),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	team, err := servicemanager.Team.FindByName(teamName)
	if err != nil || team == nil {
		return &errors.HTTP{Code: http.StatusNotFound, Message: "Team not found"}
	}
	if len(a.Teams) == 1 {
		msg := "You can not revoke the access from this team, because it is the unique team with access to the app, and an app can not be orphaned"
		return &errors.HTTP{Code: http.StatusForbidden, Message: msg}
	}
	err = a.Revoke(team)
	switch err {
	case app.ErrNoAccess:
		return &errors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
	case app.ErrCannotOrphanApp:
		return &errors.HTTP{Code: http.StatusForbidden, Message: err.Error()}
	default:
		return err
	}
}
func revokeAppAccess(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) {
	appName := r.URL.Query().Get(":app")
	teamName := r.URL.Query().Get(":team")
	a, err := getAppFromContext(appName, r)
	if err != nil {
		return err
	}
	allowed := permission.Check(t, permission.PermAppUpdateRevoke,
		contextsForApp(&a)...,
	)
	if !allowed {
		return permission.ErrUnauthorized
	}
	evt, err := event.New(&event.Opts{
		Target:     appTarget(appName),
		Kind:       permission.PermAppUpdateRevoke,
		Owner:      t,
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermAppReadEvents, contextsForApp(&a)...),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	team, err := servicemanager.Team.FindByName(teamName)
	if err != nil || team == nil {
		return &errors.HTTP{Code: http.StatusNotFound, Message: "Team not found"}
	}
	if len(a.Teams) == 1 {
		msg := "You can not revoke the access from this team, because it is the unique team with access to the app, and an app can not be orphaned"
		return &errors.HTTP{Code: http.StatusForbidden, Message: msg}
	}
	err = a.Revoke(team)
	switch err {
	case app.ErrNoAccess:
		return &errors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
	case app.ErrCannotOrphanApp:
		return &errors.HTTP{Code: http.StatusForbidden, Message: err.Error()}
	default:
		return err
	}
}
func revokeAppAccess ( w http . ResponseWriter , r * http . Request , t auth . Token ) ( err error ) { appName := r . URL . Query ( ) . Get ( " " ) teamName := r . URL . Query ( ) . Get ( " " ) a , err := getAppFromContext ( appName , r ) if err != nil { return err } allowed := permission . Check ( t , permission . PermAppUpdateRevoke , contextsForApp ( & a ) ... , ) if ! allowed { return permission . ErrUnauthorized } evt , err := event . New ( & event . Opts { Target : appTarget ( appName ) , Kind : permission . PermAppUpdateRevoke , Owner : t , CustomData : event . FormToCustomData ( InputFields ( r ) ) , Allowed : event . Allowed ( permission . PermAppReadEvents , contextsForApp ( & a ) ... ) , } ) if err != nil { return err } defer func ( ) { evt . Done ( err ) } ( ) team , err := servicemanager . Team . FindByName ( teamName ) if err != nil || team == nil { return & errors . HTTP { Code : http . StatusNotFound , Message : " " } } if len ( a . Teams ) == 1 { msg := " " return & errors . HTTP { Code : http . StatusForbidden , Message : msg } } err = a . Revoke ( team ) switch err { case app . ErrNoAccess : return & errors . HTTP { Code : http . StatusNotFound , Message : err . Error ( ) } case app . ErrCannotOrphanApp : return & errors . HTTP { Code : http . StatusForbidden , Message : err . Error ( ) } default : return err } }
// title: revoke access to app
// path: /apps/{app}/teams/{team}
// method: DELETE
// responses:
//   200: Access revoked
//   401: Unauthorized
//   403: Forbidden
//   404: App or team not found
title : revoke access to app path : / apps / { app } / teams / { team } method : DELETE responses : 200 : Access revoked 401 : Unauthorized 403 : Forbidden 404 : App or team not found