services

package
v1.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateRefreshToken

func CreateRefreshToken(userID string) (string, error)

func CreateWebToken

func CreateWebToken(user foundation.User) (string, error)

func DecodeToken

func DecodeToken(tokenString string) (jwt.MapClaims, error)

func GenerateRecoveryToken

func GenerateRecoveryToken(email string) (string, error)

func GenerateShortCode

func GenerateShortCode(length int) string

func GetBaseRequest

func GetBaseRequest(request *ServiceRequest) (*foundation.BaseRequest, error)

func GetClaimsFromToken

func GetClaimsFromToken(token string) (jwt.MapClaims, error)

func GetClientIP

func GetClientIP(ipHeader, realIPHeader, remoteAddr string) string

GetClientIP extracts the client IP from the request headers

func NewBaseRequestFromServiceRequest

func NewBaseRequestFromServiceRequest(request *ServiceRequest) (*foundation.BaseRequest, error)

func NewBaseRequestFromServiceRequestWithIDs

func NewBaseRequestFromServiceRequestWithIDs(request *ServiceRequest, baseModel *foundation.BaseModel) *foundation.BaseRequest

func NewFoundationBaseRequest

func NewFoundationBaseRequest(request *ServiceRequest) (*foundation.BaseRequest, error)

func NewFoundationBaseRequestWithRepository

func NewFoundationBaseRequestWithRepository(request *ServiceRequest) (*foundation.BaseRequest, error)

func ProcessPasswordRecovery

func ProcessPasswordRecovery(email, xForwardedFor, xRealIP, remoteAddr, userAgent, referer string) error

ProcessPasswordRecovery handles the password recovery process

func ResetPassword

func ResetPassword(email string, newPassword string) error

func SendEmail

func SendEmail(to string, subject string, body string, channel log.HookChannel) error

TODO: que alguien estudie interfaces por favor

func SendEmailMobile

func SendEmailMobile(to, recoveryCode string) error

func SendEmailRecovery added in v1.7.0

func SendEmailRecovery(to string, recoveryToken string) error

SendEmailRecovery envía un correo electrónico de recuperación de contraseña al destinatario especificado. Utiliza Microsoft Graph API para enviar el correo electrónico y notifica a Discord sobre el estado de la operación. Devuelve un error genérico si ocurre algún problema durante el proceso.

func UpdateToken

func UpdateToken(token string) (string, error)

func UserExistsByEmail

func UserExistsByEmail(email string) (bool, error)

ResetPassword restablece la contraseña de un usuario. Busca al usuario por su correo electrónico y actualiza su contraseña en la base de datos. Devuelve un error si el usuario no se encuentra o si ocurre algún problema durante la actualización. UserExistsByEmail checks if a user with the given email exists in the database

func ValidateRecoveryToken

func ValidateRecoveryToken(tokenString string) (bool, error)

ValidateRecoveryToken valida un token de recuperación de contraseña. Verifica que el token sea válido, no haya expirado y esté firmado correctamente. Devuelve true si el token es válido, o false y un error en caso contrario.

Types

type ExerciseClusterRequest

type ExerciseClusterRequest struct {
	ServiceRequest *ServiceRequest
	Level          int
	AccountCode    string
	EntryNumber    string
	ParentID       *primitive.ObjectID
}

func NewExerciseClusterRequest

func NewExerciseClusterRequest(request *ServiceRequest, level int) *ExerciseClusterRequest

type ImportedDataRequest

type ImportedDataRequest struct {
	ServiceRequest
	ImportedDataID primitive.ObjectID
}

type ServiceRequest

type ServiceRequest struct {
	Errors []error
	ID     *primitive.ObjectID
	IDs    interface{}
	// Puede cambiar el campo ID que por defecto es "_id"
	QueryField  string
	RepoID      string
	Language    foundation.Language
	Location    string
	PageSize    int64
	CurrentPage int64
	List        interface{}
	Date        *time.Time
	Order       *foundation.Orders
	Collation   *options.Collation
	SearchTerms foundation.SearchTerms
	Labels      []string
	Connection  string
	foundation.DateRange
	Repo         foundation.Repository
	RepoModel    foundation.RepositoryModel
	ParseModel   interface{}
	Token        string
	RefreshToken string
	User         foundation.User
	SpaceID      string
}

func FillRequestFromToken

func FillRequestFromToken(request *ServiceRequest) (*ServiceRequest, error)

func NewServiceRequest

func NewServiceRequest() *ServiceRequest

func NewServiceRequestFromBaseModel

func NewServiceRequestFromBaseModel(m *foundation.BaseModel, user *foundation.User) *ServiceRequest

func NewServiceRequestFromUser

func NewServiceRequestFromUser(user *foundation.User) (*ServiceRequest, error)

func NewServiceRequestWithSpaceID

func NewServiceRequestWithSpaceID(id string, repoID string, user foundation.User, language foundation.Language) (*ServiceRequest, error)

func (*ServiceRequest) AddID

func (m *ServiceRequest) AddID(id interface{})

func (*ServiceRequest) AddOrderAsc

func (m *ServiceRequest) AddOrderAsc(fields ...string)

func (*ServiceRequest) AddOrderDesc

func (m *ServiceRequest) AddOrderDesc(fields ...string)

func (*ServiceRequest) ChangeUser

func (m *ServiceRequest) ChangeUser(user *foundation.User) error

func (*ServiceRequest) GetUser

func (m *ServiceRequest) GetUser() *foundation.User

func (*ServiceRequest) HasBasicInfo

func (m *ServiceRequest) HasBasicInfo() bool

func (*ServiceRequest) HasOrderField

func (m *ServiceRequest) HasOrderField(field string) bool

func (*ServiceRequest) HasUser

func (m *ServiceRequest) HasUser() bool

func (*ServiceRequest) HasValidUser

func (m *ServiceRequest) HasValidUser() bool

func (*ServiceRequest) IsEmpty

func (m *ServiceRequest) IsEmpty() bool

func (*ServiceRequest) ToJSON

func (m *ServiceRequest) ToJSON() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL