~netlandish/gobwebs

63f2a61632eaee5fc9a6d24b892375d1dc11e44e — Peter Sanchez 1 year, 3 months ago 0848a1f
Don't panic when a user isn't in context
1 files changed, 1 insertions(+), 2 deletions(-)

M auth/middleware.go
M auth/middleware.go => auth/middleware.go +1 -2
@@ 2,7 2,6 @@ package auth

import (
	"context"
	"errors"
	"fmt"
	"net/http"
	"net/url"


@@ 28,7 27,7 @@ func Context(ctx context.Context, user gobwebs.User) context.Context {
func ForContext(ctx context.Context) gobwebs.User {
	user, ok := ctx.Value(userCtxKey).(gobwebs.User)
	if !ok {
		panic(errors.New("invalid user context"))
		return nil
	}
	return user
}