user

package
v0.0.0-...-47484d2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GithubToken

type GithubToken struct {
	AccessToken  string `json:"access_token,omitempty"`
	TokenType    string `json:"token_type,omitempty"`
	Scope        string `json:"scope,omitempty"`
	ErrorMessage string `json:"error,omitempty"`
	ErrorDesc    string `json:"error_description,omitempty"`
	ErrorURI     string `json:"error_uri,omitempty"`
}

GithubToken ..

func NewGithubTokenErr

func NewGithubTokenErr() *GithubToken

NewGithubTokenErr ..

func NewGithubTokenResp

func NewGithubTokenResp(accessToken, tokenType, scope string) *GithubToken

NewGithubTokenResp ..

type GithubUser

type GithubUser struct {
	Name      string `json:"name"`
	Login     string `json:"login"`
	AvatarURL string `json:"avatar_url"`
	ID        uint64 `json:"id"`
}

GithubUser ..

type Handler

type Handler interface {
	common.BaseHandler
	OauthGithub(c *gin.Context)
	RefreshToken(c *gin.Context)
	GetAuthenticatedUser(c *gin.Context)
	UpdateAuthenticatedUser(c *gin.Context)
}

Handler has user GIN handlers, it is the adapter layer

func NewHandler

func NewHandler(service Service, guard crypto.JWTGuard) Handler

NewHandler ...

type OauthRepo

type OauthRepo interface {
	GetUserOauthToken(code string) (*GithubToken, error)
	GetUserOauthInfo(token string) (*GithubUser, error)
}

OauthRepo abstract github oauth repo layer logic

func NewGithubRepo

func NewGithubRepo(restClient *resty.Client, logger *logrus.Logger) OauthRepo

NewGithubRepo create a new githubRepo instance

type Repository

type Repository interface {
	Create(user *models.UserModel) error
	ReadByID(id uint64) (*models.UserModel, error)
	ReadByGithubID(id uint64) (*models.UserModel, error)
	UpdateWithStruct(user *models.UserModel, newUser *models.UserModel) error
}

Repository abstract user repository layer logic

type Service

type Service interface {
	GetByID(id uint64) (*models.UserModel, error)
	UpdateByID(id uint64, newUser *models.UserModel) (*models.UserModel, error)
	// VerifyUserRefreshToken(id string, token string) (*models.UserModel, error)
	GetOrCreateUserWithGithubOauth(code string) (*models.UserModel, error)
}

Service abstract a yishan user's business logic

func NewUserService

func NewUserService(repo Repository, githubRepo OauthRepo) Service

NewUserService create new user service

Jump to

Keyboard shortcuts

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