feat: prototyping possible interaction of database, controllers, services with auth service
This commit is contained in:
@@ -9,18 +9,48 @@ import (
|
||||
)
|
||||
|
||||
type AuthService interface {
|
||||
RegistrationBegin(request models.RegistrationBeginRequest) (bool, error)
|
||||
RegistrationComplete(request models.RegistrationBeginRequest) (*models.RegistrationCompleteResponse, error)
|
||||
Login(request models.LoginRequest) (*models.LoginResponse, error)
|
||||
Refresh(request models.RefreshRequest) (*models.RefreshResponse, error)
|
||||
}
|
||||
|
||||
type authServiceImpl struct {
|
||||
|
||||
}
|
||||
|
||||
func NewAuthService() AuthService {
|
||||
return &authServiceImpl{}
|
||||
}
|
||||
|
||||
func (a *authServiceImpl) RegistrationBegin(request models.RegistrationBeginRequest) (bool, error) {
|
||||
conn, ctx, err := utils.GetDbConn()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer conn.Close(ctx)
|
||||
|
||||
queries := database.New(conn)
|
||||
|
||||
tx, err := database.Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
qtx := queries.WithTx(tx)
|
||||
|
||||
tx.Commit()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (a *authServiceImpl) RegistrationComplete(request models.RegistrationBeginRequest) (*models.RegistrationCompleteResponse, error) {
|
||||
conn, ctx, err := utils.GetDbConn()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer conn.Close(ctx)
|
||||
}
|
||||
|
||||
func (a *authServiceImpl) Login(request models.LoginRequest) (*models.LoginResponse, error) {
|
||||
conn, ctx, err := utils.GetDbConn()
|
||||
if err != nil {
|
||||
@@ -44,7 +74,6 @@ func (a *authServiceImpl) Login(request models.LoginRequest) (*models.LoginRespo
|
||||
return &models.LoginResponse{Tokens: models.Tokens{AccessToken: accessToken, RefreshToken: refreshToken}}, nil
|
||||
}
|
||||
|
||||
|
||||
func (a *authServiceImpl) Refresh(request models.RefreshRequest) (*models.RefreshResponse, error) {
|
||||
return nil, errors.ErrNotImplemented
|
||||
return nil, errors.ErrNotImplemented
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user