Documentation
¶
Index ¶
- Constants
- Variables
- func GetAuthTokenByRefreshToken(c *gin.Context)
- func GetCaptchaImage(c *gin.Context)
- func GetCaptchaInfo(c *gin.Context)
- func GetChatWSToken(c *gin.Context)
- func GetGoogleOAuthURL(c *gin.Context)
- func GoogleOAuthBind(c *gin.Context)
- func GoogleOAuthRedirectURIForBind(c *gin.Context)
- func GoogleOAuthRedirectURIForLogin(c *gin.Context)
- func UpdateCaptchaInfo(c *gin.Context)
Constants ¶
const ( ErrCodeRequestQueryParamsAccountUUIDFieldNotValid string = "err-400-rqpaufnv" ErrMessageRequestQueryParamsAccountUUIDFieldNotValid string = "query string 'accountUuid' in not valid" ErrCodeRequestQueryParamsOAuthURLTypeFieldNotValid string = "err-400-rqpoutfnv" ErrMessageRequestQueryParamsOAuthURLTypeFieldNotValid string = "query string 'type' in not valid ('login' or 'bind')" ErrCodeRequestQueryParamEmailFieldNotValid string = "err-400-rqpefnv" ErrMessageRequestQueryParamEmailFieldNotValid string = "query string 'email' in not valid" ErrCodeRequestRecordAlreadyExistWhenOAuthBinding string = "err-409-rraewoab" ErrMessageRequestRecordAlreadyExistWhenOAuthBinding string = "OAuth info already exist" ErrCodeRequestOAuthAccessTokenGotError string = "err-500-roatge" )
Variables ¶
var OAuthProviderName = map[string]string{
"google": "google",
}
Functions ¶
func GetAuthTokenByRefreshToken ¶
@Summary 取得 authToken @Description 使用 Cookie 中的 REFRESH_TOKEN field 來獲取 authToken @Tags auth @Accept json @Produce json @Success 200 {object} controllers.JSONResponse{data=getAuthTokenByRefreshTokenResponsePayload} @Failure 400 {object} controllers.JSONResponse @Failure 401 {object} controllers.JSONResponse @Failure 500 {object} controllers.JSONResponse @Router /auth/session/token/refresh [get]
func GetCaptchaImage ¶
@Summary 取得圖形驗證圖片 @Description 取得與 UUID 相對應的驗證圖片 @Tags auth @Accept json @Produce json @Param captchaUUID path string true "Captcha Info" @Success 200 {string} content-type "image/png" @Failure 500 {object} controllers.JSONResponse @Router /auth/captcha/{captchaUUID}/image [get]
func GetCaptchaInfo ¶
@Summary 取得圖形驗證相關資訊 @Description 取得圖形驗證動態產生的相對應 UUID 及驗證圖片 @Tags auth @Accept json @Produce json @Success 200 {object} controllers.JSONResponse{data=getCaptchaInfoResponsePayload} @Failure 500 {object} controllers.JSONResponse @Router /auth/captcha [get]
func GetChatWSToken ¶
@Summary 取得 Chat WebSocket 連線用 Token @Description 取得 Chat WebSocket 連線用 Token (1 分鐘效期) @Tags auth @Accept json @Produce json @Security ApiKeyAuth @Success 200 {object} controllers.JSONResponse{data=getChatWSTokenResponse} @Failure 500 {object} controllers.JSONResponse @Router /auth/chat/ws/token [get]
func GetGoogleOAuthURL ¶
@Summary 取得 Google OAuth 相關 URL @Description 帶上 type (login, bind) 來表示要取得的是登入用,還是綁定第三方登入用,以及 redirectPath 表示成功後所導轉的終點 @Tags auth @Accept json @Produce json @Param type query string true "login or bind" @Param redirectPath query string true "導轉終點" @Success 200 {object} controllers.JSONResponse{data=getOAuthUrlResponsePayload} @Failure 400 {object} controllers.JSONResponse @Router /auth/o/google/url [get]
func GoogleOAuthBind ¶
@Summary 更新 Account 第三方登入綁定資訊 @Description 更新 Account 第三方登入綁定資訊 @Tags auth @Accept json @Produce json @Security ApiKeyAuth @Param grantCode body string true "Google grant code (from google)" @Success 200 {object} controllers.JSONResponse @Failure 400 {object} controllers.JSONResponse @Failure 409 {object} controllers.JSONResponse @Failure 500 {object} controllers.JSONResponse @Router /auth/o/google/bind [patch]
func GoogleOAuthRedirectURIForBind ¶
@Summary Google OAuth 登入且授權成功後所導轉的 URI (綁定用) @Description 拿到 Google 給的 grant code 後導轉去指定前端頁面路徑 (導轉路徑為 "[GET]取得 Google OAuth 相關 URL" 當初打 API 時給什麼路徑就轉去那) @Tags auth @Accept json @Produce json @Param code query string true "Google grant code (from google)" @Param state query string true "Front end redirect path (from google OAuth state QS)" @Success 302 @Failure 400 {object} controllers.JSONResponse @Router /auth/o/google/bind [get]
func GoogleOAuthRedirectURIForLogin ¶
TODO: 登入、註冊有很多重複的 CODE 需要整理 @Summary Google OAuth 登入且授權成功後所導轉的 URI (登入用) @Description 拿到 Google 給的 grant code 後再去和 Google 拿 access token,再用 access token 去拿該 user 的相關資訊 (scope),若失敗會在 QS 加上 oauth_login_failed=1 @Tags auth @Accept json @Produce json @Param code query string true "Google grant code (from google)" @Param state query string true "Front end redirect path (from google OAuth state QS)" @Success 302 @Failure 302 @Failure 400 {object} controllers.JSONResponse @Failure 500 {object} controllers.JSONResponse @Router /auth/o/google/login [get]
func UpdateCaptchaInfo ¶
@Summary 刷新圖形驗證 @Description 刷新與 UUID 相對應的驗證圖片資訊及效期 @Tags auth @Accept json @Produce json @Param captchaUUID path string true "Captcha Info" @Success 200 {object} controllers.JSONResponse @Failure 500 {object} controllers.JSONResponse @Router /auth/captcha/{captchaUUID}/refresh [get]
Types ¶
This section is empty.