func resetPassword(w http.ResponseWriter, r *http.Request) (err error) {
	managed, ok := app.AuthScheme.(auth.ManagedScheme)
	if !ok {
		return &errors.HTTP{Code: http.StatusBadRequest, Message: nonManagedSchemeMsg}
	}
	email := r.URL.Query().Get(":email")
	token := InputValue(r, "token")
	evt, err := event.New(&event.Opts{
		Target:     userTarget(email),
		Kind:       permission.PermUserUpdateReset,
		RawOwner:   event.Owner{Type: event.OwnerTypeUser, Name: email},
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermUserReadEvents, permission.Context(permTypes.CtxUser, email)),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	u, err := auth.GetUserByEmail(email)
	if err != nil {
		if err == authTypes.ErrUserNotFound {
			return &errors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
		}
		return err
	}
	if token == "" {
		return managed.StartPasswordReset(u)
	}
	return managed.ResetPassword(u, token)
}
func resetPassword(w http.ResponseWriter, r *http.Request) (err error) {
	managed, ok := app.AuthScheme.(auth.ManagedScheme)
	if !ok {
		return &errors.HTTP{Code: http.StatusBadRequest, Message: nonManagedSchemeMsg}
	}
	email := r.URL.Query().Get(":email")
	token := InputValue(r, "token")
	evt, err := event.New(&event.Opts{
		Target:     userTarget(email),
		Kind:       permission.PermUserUpdateReset,
		RawOwner:   event.Owner{Type: event.OwnerTypeUser, Name: email},
		CustomData: event.FormToCustomData(InputFields(r)),
		Allowed:    event.Allowed(permission.PermUserReadEvents, permission.Context(permTypes.CtxUser, email)),
	})
	if err != nil {
		return err
	}
	defer func() { evt.Done(err) }()
	u, err := auth.GetUserByEmail(email)
	if err != nil {
		if err == authTypes.ErrUserNotFound {
			return &errors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
		}
		return err
	}
	if token == "" {
		return managed.StartPasswordReset(u)
	}
	return managed.ResetPassword(u, token)
}
func resetPassword ( w http . ResponseWriter , r * http . Request ) ( err error ) { managed , ok := app . AuthScheme . ( auth . ManagedScheme ) if ! ok { return & errors . HTTP { Code : http . StatusBadRequest , Message : nonManagedSchemeMsg } } email := r . URL . Query ( ) . Get ( " " ) token := InputValue ( r , " " ) evt , err := event . New ( & event . Opts { Target : userTarget ( email ) , Kind : permission . PermUserUpdateReset , RawOwner : event . Owner { Type : event . OwnerTypeUser , Name : email } , CustomData : event . FormToCustomData ( InputFields ( r ) ) , Allowed : event . Allowed ( permission . PermUserReadEvents , permission . Context ( permTypes . CtxUser , email ) ) , } ) if err != nil { return err } defer func ( ) { evt . Done ( err ) } ( ) u , err := auth . GetUserByEmail ( email ) if err != nil { if err == authTypes . ErrUserNotFound { return & errors . HTTP { Code : http . StatusNotFound , Message : err . Error ( ) } } return err } if token == " " { return managed . StartPasswordReset ( u ) } return managed . ResetPassword ( u , token ) }
// title: reset password
// path: /users/{email}/password
// method: POST
// responses:
//   200: Ok
//   400: Invalid data
//   401: Unauthorized
//   403: Forbidden
//   404: Not found
title : reset password path : / users / { email } / password method : POST responses : 200 : Ok 400 : Invalid data 401 : Unauthorized 403 : Forbidden 404 : Not found