27 lines
682 B
Go
27 lines
682 B
Go
package dynamodb
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/authorizerdev/authorizer/server/db/models"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// AddSession to save session information in database
|
|
func (p *provider) AddSession(ctx context.Context, session *models.Session) error {
|
|
collection := p.db.Table(models.Collections.Session)
|
|
if session.ID == "" {
|
|
session.ID = uuid.New().String()
|
|
}
|
|
session.CreatedAt = time.Now().Unix()
|
|
session.UpdatedAt = time.Now().Unix()
|
|
err := collection.Put(session).RunWithContext(ctx)
|
|
return err
|
|
}
|
|
|
|
// DeleteSession to delete session information from database
|
|
func (p *provider) DeleteSession(ctx context.Context, userId string) error {
|
|
return nil
|
|
}
|