Documentation
¶
Index ¶
- Variables
- func ComparePassword(hashValue, plain string) bool
- func Created(c *fiber.Ctx, message string, data interface{}) error
- func Fail(c *fiber.Ctx, status int, message string, errs interface{}) error
- func GenerateTOTPSecret(issuer, accountEmail string) (secret string, qrBase64 string, err error)
- func HashPassword(plain string) (string, error)
- func NoContent(c *fiber.Ctx) error
- func NotFound(c *fiber.Ctx) error
- func OK(c *fiber.Ctx, message string, data interface{}) error
- func OKWithMeta(c *fiber.Ctx, message string, data interface{}, meta interface{}) error
- func ParseAndValidate(c *fiber.Ctx, out interface{}) bool
- func ParseUintSubject(subject string) uint
- func UintToString(u uint) string
- func VerifyTOTP(code, secret string) bool
- type DeviceInfo
- type DeviceType
- type Envelope
- type FieldError
- type JWTClaims
- type JWTService
- func (s *JWTService) GenerateAccessToken(userID, roleID, sessionID uint, roleName string) (string, error)
- func (s *JWTService) GenerateRefreshToken(userID uint) (string, time.Time, error)
- func (s *JWTService) ParseAccessToken(tokenStr string) (*JWTClaims, error)
- func (s *JWTService) ParseRefreshToken(tokenStr string) (*jwt.RegisteredClaims, error)
- type PaginationMeta
- type PaginationParams
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New("data ga ditemukan") ErrAlreadyExists = errors.New("data sudah ada") ErrInvalidCredential = errors.New("username atau password salah") ErrInvalidOTP = errors.New("kode OTP salah atau sudah kedaluwarsa") ErrForbiddenModule = errors.New("role kamu tidak memiliki izin mengakses modul ini") ErrTokenExpired = errors.New("token sudah kadaluarsa, coba login kembali") ErrAccountInactive = errors.New("akun kamu ga aktif, hubungi admin") )
Functions ¶
func ComparePassword ¶
func GenerateTOTPSecret ¶
func HashPassword ¶
func OKWithMeta ¶
func ParseAndValidate ¶
func ParseUintSubject ¶
func UintToString ¶ added in v0.1.2
func VerifyTOTP ¶
Types ¶
type DeviceInfo ¶
type DeviceInfo struct {
Browser string `json:"browser"`
BrowserVersion string `json:"browser_version"`
OS string `json:"os"`
OSVersion string `json:"os_version"`
DeviceType DeviceType `json:"device_type"`
}
func ParseUserAgent ¶
func ParseUserAgent(userAgent string) DeviceInfo
func (DeviceInfo) String ¶
func (d DeviceInfo) String() string
type DeviceType ¶
type DeviceType string
const ( DeviceDesktop DeviceType = "desktop" DeviceMobile DeviceType = "mobile" DeviceTablet DeviceType = "tablet" DeviceUnknown DeviceType = "unknown" )
type FieldError ¶
func Validate ¶
func Validate(payload interface{}) []FieldError
type JWTService ¶
type JWTService struct {
// contains filtered or unexported fields
}
func NewJWTService ¶
func NewJWTService(cfg *config.JWTConfig) *JWTService
func (*JWTService) GenerateAccessToken ¶
func (s *JWTService) GenerateAccessToken(userID, roleID, sessionID uint, roleName string) (string, error)
func (*JWTService) GenerateRefreshToken ¶
func (*JWTService) ParseAccessToken ¶
func (s *JWTService) ParseAccessToken(tokenStr string) (*JWTClaims, error)
func (*JWTService) ParseRefreshToken ¶
func (s *JWTService) ParseRefreshToken(tokenStr string) (*jwt.RegisteredClaims, error)
type PaginationMeta ¶
type PaginationMeta struct {
Page int `json:"page"`
Limit int `json:"limit"`
TotalItems int64 `json:"total_items"`
TotalPages int `json:"total_pages"`
}
func BuildPaginationMeta ¶
func BuildPaginationMeta(p PaginationParams, total int64) PaginationMeta
type PaginationParams ¶
func PaginationFromContext ¶
func PaginationFromContext(c *fiber.Ctx) PaginationParams
Click to show internal directories.
Click to hide internal directories.