fix(auth): the header is called Authorization not Authentication

This commit is contained in:
overflowerror 2021-08-14 19:31:13 +02:00
parent bb350e6c2d
commit ad9bbed9be
2 changed files with 19 additions and 2 deletions

View file

@ -0,0 +1,17 @@
package presentation
import "threadule/backend/internal/web"
func GetAccounts(ctx *web.Context) {
accounts, err := ctx.AppCtx.Logic.GetAccounts(ctx.Session.User)
if err != nil {
ErrorResponse(ctx, err)
return
}
err = ctx.WriteJSON(accounts)
if err != nil {
ErrorResponse(ctx, err)
return
}
}

View file

@ -11,9 +11,9 @@ const authPrefix = "Bearer "
func authenticated(next web.Handler) web.Handler {
return func(ctx *web.Context) {
authHeader := ctx.Request.Header.Get("Authentication")
authHeader := ctx.Request.Header.Get("Authorization")
if !strings.HasPrefix(authHeader, authPrefix) {
StatusResponse(ctx, http.StatusBadRequest, "Authentication header missing or malformed")
StatusResponse(ctx, http.StatusBadRequest, "Authorization header missing or malformed")
return
}
authHeader = strings.TrimPrefix(authHeader, authPrefix)