align types with new db schema

This commit is contained in:
Hayden 2022-08-30 10:05:11 -08:00
parent 63cfeffc4d
commit b83505104a
30 changed files with 1491 additions and 263 deletions

View file

@ -3,7 +3,7 @@ package services
import (
"context"
"github.com/hay-kot/content/backend/internal/types"
"github.com/hay-kot/content/backend/ent"
)
type contextKeys struct {
@ -17,16 +17,16 @@ var (
// SetUserCtx is a helper function that sets the ContextUser and ContextUserToken
// values within the context of a web request (or any context).
func SetUserCtx(ctx context.Context, user *types.UserOut, token string) context.Context {
func SetUserCtx(ctx context.Context, user *ent.User, token string) context.Context {
ctx = context.WithValue(ctx, ContextUser, user)
ctx = context.WithValue(ctx, ContextUserToken, token)
return ctx
}
// UseUserCtx is a helper function that returns the user from the context.
func UseUserCtx(ctx context.Context) *types.UserOut {
func UseUserCtx(ctx context.Context) *ent.User {
if val := ctx.Value(ContextUser); val != nil {
return val.(*types.UserOut)
return val.(*ent.User)
}
return nil
}