feat: add ping endpoint to check auth status
This commit is contained in:
parent
06f37bf3d8
commit
c416b40d00
|
@ -264,6 +264,12 @@ func (a AccountAPI) passwordResetConfirm(jc jape.Context) {
|
||||||
jc.ResponseWriter.WriteHeader(http.StatusOK)
|
jc.ResponseWriter.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a AccountAPI) pong(jc jape.Context) {
|
||||||
|
jc.Encode(&PongResponse{
|
||||||
|
Ping: "pong",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (a AccountAPI) Routes() (*httprouter.Router, error) {
|
func (a AccountAPI) Routes() (*httprouter.Router, error) {
|
||||||
authMw2fa := authMiddleware(middleware.AuthMiddlewareOptions{
|
authMw2fa := authMiddleware(middleware.AuthMiddlewareOptions{
|
||||||
Identity: a.identity,
|
Identity: a.identity,
|
||||||
|
@ -280,6 +286,7 @@ func (a AccountAPI) Routes() (*httprouter.Router, error) {
|
||||||
})
|
})
|
||||||
|
|
||||||
routes := map[string]jape.Handler{
|
routes := map[string]jape.Handler{
|
||||||
|
"POST /api/auth/ping": middleware.ApplyMiddlewares(a.pong, authMw2fa, middleware.ProxyMiddleware),
|
||||||
"POST /api/auth/login": middleware.ApplyMiddlewares(a.login, authMw2fa, middleware.ProxyMiddleware),
|
"POST /api/auth/login": middleware.ApplyMiddlewares(a.login, authMw2fa, middleware.ProxyMiddleware),
|
||||||
"POST /api/auth/register": middleware.ApplyMiddlewares(a.register, middleware.ProxyMiddleware),
|
"POST /api/auth/register": middleware.ApplyMiddlewares(a.register, middleware.ProxyMiddleware),
|
||||||
"POST /api/auth/verify-email": middleware.ApplyMiddlewares(a.verifyEmail, middleware.ProxyMiddleware),
|
"POST /api/auth/verify-email": middleware.ApplyMiddlewares(a.verifyEmail, middleware.ProxyMiddleware),
|
||||||
|
|
|
@ -42,3 +42,7 @@ type PasswordResetVerifyRequest struct {
|
||||||
Token string `json:"token"`
|
Token string `json:"token"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PongResponse struct {
|
||||||
|
Ping string `json:"ping"`
|
||||||
|
}
|
||||||
|
|
|
@ -118,6 +118,14 @@ paths:
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Password reset successfully
|
description: Password reset successfully
|
||||||
|
/api/auth/pong:
|
||||||
|
get:
|
||||||
|
summary: Auth check endpoint
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Pong
|
||||||
|
'401':
|
||||||
|
description: Unauthorized
|
||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
|
|
Loading…
Reference in New Issue