- Replace dual update systems with single markdown-first editor architecture - Add server-side upsert to eliminate 404 errors on PUT operations - Fix content persistence race condition between preview and save operations - Remove legacy updateElementContent system entirely - Add comprehensive authentication with JWT scaffolding and dev mode - Implement EditContext.updateOriginalContent() for proper baseline management - Enable markdown formatting in all text elements (h1-h6, p, div, etc) - Clean terminology: remove 'unified' references from codebase Technical changes: * core/editor.js: Remove legacy update system, unify content types as markdown * ui/Editor.js: Add updateOriginalContent() method to fix save persistence * ui/Previewer.js: Clean live preview system for all content types * api/handlers.go: Implement UpsertContent for idempotent PUT operations * auth/*: Complete authentication service with OAuth scaffolding * db/queries/content.sql: Add upsert query with ON CONFLICT handling * Schema: Remove type constraints, rely on server-side validation Result: Clean content editing with persistent saves, no 404 errors, markdown support in all text elements
30 lines
760 B
Go
30 lines
760 B
Go
package auth
|
|
|
|
import "context"
|
|
|
|
// Context keys for user information
|
|
type contextKey string
|
|
|
|
const (
|
|
userInfoContextKey contextKey = "user_info"
|
|
)
|
|
|
|
// ContextWithUser adds user information to request context
|
|
func ContextWithUser(ctx context.Context, user *UserInfo) context.Context {
|
|
return context.WithValue(ctx, userInfoContextKey, user)
|
|
}
|
|
|
|
// UserFromContext extracts user information from request context
|
|
func UserFromContext(ctx context.Context) (*UserInfo, bool) {
|
|
user, ok := ctx.Value(userInfoContextKey).(*UserInfo)
|
|
return user, ok
|
|
}
|
|
|
|
// UserIDFromContext extracts user ID from request context
|
|
func UserIDFromContext(ctx context.Context) string {
|
|
if user, ok := UserFromContext(ctx); ok && user != nil {
|
|
return user.ID
|
|
}
|
|
return "anonymous"
|
|
}
|