features/move-domain-for-portal #8
@ -5,7 +5,7 @@ import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/domain"
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/entity"
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/repository"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
@ -16,7 +16,7 @@ const (
|
||||
|
||||
type RefreshToken interface {
|
||||
Create(ctx context.Context, username string) (string, error)
|
||||
GetByName(ctx context.Context, name string) (domain.RefreshTokenEntity, error)
|
||||
GetByName(ctx context.Context, name string) (entity.RefreshTokenEntity, error)
|
||||
Delete(ctx context.Context, id int64) (int64, error)
|
||||
IsRequestValid(ctx context.Context, username, refreshToken string) error
|
||||
}
|
||||
@ -64,7 +64,7 @@ func (rt RefreshTokenService) Create(ctx context.Context, username string) (stri
|
||||
}
|
||||
|
||||
// Find the saved refresh token for a user and return it if it exists
|
||||
func (rt RefreshTokenService) GetByName(ctx context.Context, name string) (domain.RefreshTokenEntity, error) {
|
||||
func (rt RefreshTokenService) GetByName(ctx context.Context, name string) (entity.RefreshTokenEntity, error) {
|
||||
return rt.table.GetByUsername(ctx, name)
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,8 @@ import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/domain"
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/domain"
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/entity"
|
||||
"git.jamestombleson.com/jtom38/newsbot-api/internal/repository"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
@ -21,10 +22,10 @@ const (
|
||||
type UserServices interface {
|
||||
DoesUserExist(ctx context.Context, username string) error
|
||||
DoesPasswordMatchHash(ctx context.Context, username, password string) error
|
||||
GetUser(ctx context.Context, username string) (domain.UserEntity, error)
|
||||
GetUser(ctx context.Context, username string) (entity.UserEntity, error)
|
||||
AddScopes(ctx context.Context, username string, scopes []string) error
|
||||
RemoveScopes(ctx context.Context, username string, scopes []string) error
|
||||
Create(ctx context.Context, name, password, scope string) (domain.UserEntity, error)
|
||||
Create(ctx context.Context, name, password, scope string) (entity.UserEntity, error)
|
||||
CheckPasswordForRequirements(password string) error
|
||||
}
|
||||
|
||||
@ -63,7 +64,7 @@ func (us UserService) DoesPasswordMatchHash(ctx context.Context, username, passw
|
||||
return nil
|
||||
}
|
||||
|
||||
func (us UserService) GetUser(ctx context.Context, username string) (domain.UserEntity, error) {
|
||||
func (us UserService) GetUser(ctx context.Context, username string) (entity.UserEntity, error) {
|
||||
return us.repo.GetByName(ctx, username)
|
||||
}
|
||||
|
||||
@ -124,14 +125,14 @@ func (us UserService) doesScopeExist(scopes []string, target string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (us UserService) Create(ctx context.Context, name, password, scope string) (domain.UserEntity, error) {
|
||||
func (us UserService) Create(ctx context.Context, name, password, scope string) (entity.UserEntity, error) {
|
||||
err := us.CheckPasswordForRequirements(password)
|
||||
if err != nil {
|
||||
return domain.UserEntity{}, err
|
||||
return entity.UserEntity{}, err
|
||||
}
|
||||
|
||||
us.repo.Create(ctx, name, password, domain.ScopeArticleRead)
|
||||
return domain.UserEntity{}, nil
|
||||
return entity.UserEntity{}, nil
|
||||
}
|
||||
|
||||
func (us UserService) CheckPasswordForRequirements(password string) error {
|
||||
|
Loading…
Reference in New Issue
Block a user