mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
feat(provider): add github copilot device flow provider (#364)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package oauthctx
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type userIDContextKey struct{}
|
||||
|
||||
func WithUserID(ctx context.Context, userID string) context.Context {
|
||||
userID = strings.TrimSpace(userID)
|
||||
if userID == "" {
|
||||
return ctx
|
||||
}
|
||||
return context.WithValue(ctx, userIDContextKey{}, userID)
|
||||
}
|
||||
|
||||
func UserIDFromContext(ctx context.Context) string {
|
||||
userID, _ := ctx.Value(userIDContextKey{}).(string)
|
||||
return strings.TrimSpace(userID)
|
||||
}
|
||||
Reference in New Issue
Block a user