service

package
v0.0.0-...-7161ace Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// GrantTypeAccess is the grant type for access token
	GrantTypeAccess = "access"
	// GrantTypeRefresh is the grant type for refresh token
	GrantTypeRefresh = "refresh"
)

Variables

View Source
var SignedKey = "fiber-realworld"

SignedKey is the signed key of JWT

Functions

func CompareHashWithPassword

func CompareHashWithPassword(hash, password string) error

func GeneratePasswordHash

func GeneratePasswordHash(s string) (string, error)

func InitData

func InitData(ctx context.Context) error

InitData init data

func InitServiceBean

func InitServiceBean(c config.Config) []interface{}

InitServiceBean init all service instance

func ParseToken

func ParseToken(tokenString string) (*model.CustomClaims, error)

Types

type ArticleService

type ArticleService interface {
	CreateArticle(c *fiber.Ctx, req *apiv1.ArticleRequest) (*apiv1.ArticleResponse, error)
	UpdateArticle(c *fiber.Ctx, req *apiv1.ArticleRequest) (*apiv1.ArticleResponse, error)
	GetArticle(c *fiber.Ctx) (*apiv1.ArticleResponse, error)
	GetArticles(c *fiber.Ctx) (*apiv1.ArticlesResponse, error)
	FavoriteArticle(c *fiber.Ctx) (*apiv1.ArticleResponse, error)
	UnFavoriteArticle(c *fiber.Ctx) (*apiv1.ArticleResponse, error)
}

func NewArticleService

func NewArticleService() ArticleService

type AuthenticationService

type AuthenticationService interface {
	Login(c *fiber.Ctx, loginReq apisv1.LoginRequest) error
	RefreshToken(c *fiber.Ctx, refreshToken string) (*apisv1.RefreshTokenResponse, error)

	GetCurrentUser(c *fiber.Ctx) (*apisv1.LoginResponse, error)
	GetToken(c *fiber.Ctx) (string, error)
	GenerateJWTToken(email, grantType string, expireDuration time.Duration) (string, error)
	AuthRequired() fiber.Handler
	// contains filtered or unexported methods
}

AuthenticationService is the service of authentication

func NewAuthenticationService

func NewAuthenticationService() AuthenticationService

NewAuthenticationService new authentication service

type DataInit

type DataInit interface {
	Init(ctx context.Context) error
}

DataInit the service set that needs init data

type UserService

type UserService interface {
	GetUser(c *fiber.Ctx, email string) (*model.User, error)
	GetUserByEmail(c *fiber.Ctx, email string) (*apisv1.UserBase, error)
	CreateUser(c *fiber.Ctx, req apisv1.UserRequest) error
	UpdateUser(c *fiber.Ctx, req apisv1.UserRequest) error
}

func NewUserService

func NewUserService() UserService

Jump to

Keyboard shortcuts

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