Compare commits
No commits in common. "d1c5bde5c1c44125d0e6dd3b211203075ef0af9e" and "040c662826a0b08f86e3ea1ef2311e302e5ffb9e" have entirely different histories.
d1c5bde5c1
...
040c662826
|
@ -287,11 +287,9 @@ func (a AccountAPI) passwordResetConfirm(jc jape.Context) {
|
|||
}
|
||||
|
||||
func (a AccountAPI) ping(jc jape.Context) {
|
||||
token := middleware.GetAuthTokenFromContext(jc.Request.Context())
|
||||
account.EchoAuthCookie(jc, a.Name())
|
||||
jc.Encode(&PongResponse{
|
||||
Ping: "pong",
|
||||
Token: token,
|
||||
Ping: "pong",
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -45,8 +45,7 @@ type PasswordResetVerifyRequest struct {
|
|||
}
|
||||
|
||||
type PongResponse struct {
|
||||
Ping string `json:"ping"`
|
||||
Token string `json:"token"`
|
||||
Ping string `json:"ping"`
|
||||
}
|
||||
type AccountInfoResponse struct {
|
||||
ID uint `json:"id"`
|
||||
|
|
|
@ -253,8 +253,6 @@ components:
|
|||
properties:
|
||||
ping:
|
||||
type: string
|
||||
token:
|
||||
type: string
|
||||
AccountInfoResponse:
|
||||
type: object
|
||||
properties:
|
||||
|
|
|
@ -16,7 +16,6 @@ import (
|
|||
)
|
||||
|
||||
const DEFAULT_AUTH_CONTEXT_KEY = "user_id"
|
||||
const AUTH_TOKEN_CONTEXT_KEY = "auth_token"
|
||||
|
||||
type JapeMiddlewareFunc func(jape.Handler) jape.Handler
|
||||
type HttpMiddlewareFunc func(http.Handler) http.Handler
|
||||
|
@ -155,7 +154,6 @@ func AuthMiddleware(options AuthMiddlewareOptions) func(http.Handler) http.Handl
|
|||
}
|
||||
|
||||
ctx := context.WithValue(r.Context(), options.AuthContextKey, uint(userId))
|
||||
ctx = context.WithValue(r.Context(), AUTH_TOKEN_CONTEXT_KEY, authToken)
|
||||
r = r.WithContext(ctx)
|
||||
|
||||
next.ServeHTTP(w, r)
|
||||
|
@ -194,17 +192,6 @@ func GetUserFromContext(ctx context.Context, key ...string) uint {
|
|||
|
||||
return userId
|
||||
}
|
||||
|
||||
func GetAuthTokenFromContext(ctx context.Context) string {
|
||||
authToken, ok := ctx.Value(AUTH_TOKEN_CONTEXT_KEY).(string)
|
||||
|
||||
if !ok {
|
||||
panic("auth token stored in context is not of type string")
|
||||
}
|
||||
|
||||
return authToken
|
||||
}
|
||||
|
||||
func CtxAborted(ctx context.Context) bool {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
|
|
Loading…
Reference in New Issue