2022-10-02 19:38:12 +00:00
|
|
|
package dynamodb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/authorizerdev/authorizer/server/db/models"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
|
|
|
|
// AddSession to save session information in database
|
2023-07-31 11:12:11 +00:00
|
|
|
func (p *provider) AddSession(ctx context.Context, session *models.Session) error {
|
2022-10-02 19:38:12 +00:00
|
|
|
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
|
|
|
|
}
|