MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / CreateUserSession

Method CreateUserSession

internal/identity/store.go:3123–3134  ·  view source on GitHub ↗
(ctx context.Context, userID string)

Source from the content-addressed store, hash-verified

3121const SessionTTL = 7 * 24 * time.Hour
3122
3123func (s *Store) CreateUserSession(ctx context.Context, userID string) (string, error) {
3124 token := "sess_" + randomHex32() // opaque session cookie value
3125 expiresAt := time.Now().Add(SessionTTL)
3126 _, err := s.pool.Exec(ctx,
3127 `INSERT INTO user_sessions (token, user_id, created_at, expires_at) VALUES ($1, $2, $3, $4)`,
3128 token, userID, time.Now(), expiresAt,
3129 )
3130 if err != nil {
3131 return "", err
3132 }
3133 return token, nil
3134}
3135
3136func (s *Store) GetUserSession(ctx context.Context, token string) (*User, error) {
3137 u := &User{}

Callers 4

setupUserAuthFunction · 0.95
newConsentFixtureFunction · 0.95
HandleCallbackMethod · 0.80
seedUserDataFunction · 0.80

Implementers 1

Storeinternal/identity/store.go

Calls 2

randomHex32Function · 0.85
ExecMethod · 0.65

Tested by 3

setupUserAuthFunction · 0.76
newConsentFixtureFunction · 0.76
seedUserDataFunction · 0.64