Initial commit: Open sourcing all of the Maple Open Technologies code.
This commit is contained in:
commit
755d54a99d
2010 changed files with 448675 additions and 0 deletions
33
native/desktop/maplefile/internal/usecase/session/create.go
Normal file
33
native/desktop/maplefile/internal/usecase/session/create.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"codeberg.org/mapleopentech/monorepo/native/desktop/maplefile/internal/domain/session"
|
||||
)
|
||||
|
||||
type CreateUseCase struct {
|
||||
sessionRepo session.Repository
|
||||
}
|
||||
|
||||
// ProvideCreateUseCase creates the use case for Wire
|
||||
func ProvideCreateUseCase(sessionRepo session.Repository) *CreateUseCase {
|
||||
return &CreateUseCase{sessionRepo: sessionRepo}
|
||||
}
|
||||
|
||||
// Execute creates and stores a new session
|
||||
func (uc *CreateUseCase) Execute(
|
||||
userID, email, accessToken, refreshToken string,
|
||||
expiresIn time.Duration,
|
||||
) error {
|
||||
sess := &session.Session{
|
||||
UserID: userID,
|
||||
Email: email,
|
||||
AccessToken: accessToken,
|
||||
RefreshToken: refreshToken,
|
||||
ExpiresAt: time.Now().Add(expiresIn),
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
|
||||
return uc.sessionRepo.Save(sess)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue