Documentation ¶
Index ¶
- Constants
- func ValidateTokenPlaintext(tokenPlaintext string) error
- type Models
- type Role
- type RoleModel
- type Session
- type Token
- type TokenModel
- type Url
- type UrlByUserRequest
- type UrlByUserResponse
- type UrlCreateRequest
- type UrlDeleteRequest
- type UrlDeleteResponse
- type UrlModel
- func (u *UrlModel) Create(urlReq *UrlCreateRequest) (Url, error)
- func (u *UrlModel) Delete(urlUUID uuid.UUID) error
- func (u *UrlModel) Find(urlUUID uuid.UUID) *Url
- func (u *UrlModel) GetRedirect(shortUrl string) (Url, error)
- func (u *UrlModel) GetUrlByUser(userId uuid.UUID) (*[]UrlByUserResponse, error)
- type UrlResponse
- type User
- type UserLoginRequest
- type UserLoginResponse
- type UserModel
- func (u *UserModel) Activate(id uuid.UUID) error
- func (u *UserModel) GetByEmail(email string) (*User, error)
- func (u *UserModel) GetByID(id uuid.UUID) (*User, error)
- func (u *UserModel) GetRole(c echo.Context) (string, error)
- func (u *UserModel) List() ([]User, error)
- func (u *UserModel) Login(email, password string) (*User, error)
- func (u *UserModel) Register(body *UserRegisterReq) (UserResponse, error)
- type UserRegisterReq
- type UserResponse
Constants ¶
View Source
const ( ScopeActivation = "activation" ScopeAuthentication = "authentication" )
Variables ¶
This section is empty.
Functions ¶
func ValidateTokenPlaintext ¶
ValidateTokenPlaintext validates a token plaintext. token must not be empty and be 26 bytes long.
Types ¶
type Models ¶
type Models struct { Urls UrlModel Users UserModel Roles RoleModel Tokens TokenModel }
type TokenModel ¶
func (TokenModel) DeleteAllForUser ¶
func (m TokenModel) DeleteAllForUser(scope string, userID uuid.UUID) error
func (TokenModel) GetUserID ¶
func (m TokenModel) GetUserID(scope, token string) (uuid.UUID, error)
GetUserID returns a user for a given token.
func (TokenModel) Insert ¶
func (m TokenModel) Insert(token *Token) error
type Url ¶
type Url struct { gorm.Model ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primary_key" json:"id,omitempty"` Original string `gorm:"type:varchar(2048);not null;uniqueIndex" json:"original"` ShortUrl string `gorm:"type:varchar(11);not null;uniqueIndex" json:"short_url"` UserID uuid.UUID `gorm:"type:uuid" json:"user_id"` User User `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"` Visits int `gorm:"default:0" json:"visits"` }
type UrlByUserRequest ¶
type UrlByUserResponse ¶
type UrlCreateRequest ¶
type UrlDeleteRequest ¶
type UrlDeleteResponse ¶
type UrlDeleteResponse struct {
Message string `json:"message"`
}
type UrlModel ¶
Create a UrlModel struct which wraps the connection pool.
func (*UrlModel) GetUrlByUser ¶
func (u *UrlModel) GetUrlByUser(userId uuid.UUID) (*[]UrlByUserResponse, error)
GetUrlByUser returns all URLs for a given user
type UrlResponse ¶
type UserLoginRequest ¶
type UserLoginResponse ¶
type UserModel ¶
func (*UserModel) GetByEmail ¶
GetByEmail returns a user based on the email address.
func (*UserModel) Register ¶
func (u *UserModel) Register(body *UserRegisterReq) (UserResponse, error)
type UserRegisterReq ¶
Click to show internal directories.
Click to hide internal directories.