Session.create constructor

Session.create(
  1. String userId,
  2. Duration duration
)

Create a new session

Implementation

factory Session.create(String userId, Duration duration) {
  final now = DateTime.now();
  return Session(
    id: now.millisecondsSinceEpoch.toString() + '_' + userId,
    userId: userId,
    createdAt: now,
    expiresAt: now.add(duration),
  );
}