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 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
type OauthRepo ¶
type OauthRepo interface { GetUserOauthToken(code string) (*GithubToken, error) GetUserOauthInfo(token string) (*GithubUser, error) }
OauthRepo abstract github oauth repo layer logic
func NewGithubRepo ¶
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
Click to show internal directories.
Click to hide internal directories.