Documentation ¶
Index ¶
- func ComparePasswords(ctx context.Context, password string, hash []byte) (bool, error)
- func GenerateEncryptedPassword(ctx context.Context, password string) ([]byte, error)
- func VerifyPassword(password string) error
- type IAuthRedisRepository
- type IUseCase
- type RedisRepository
- type UseCase
- func (a *UseCase) Login(ctx context.Context, password string, email string) (string, error)
- func (a *UseCase) LoginOauth(ctx context.Context, user domain.User) (string, error)
- func (*UseCase) Logout(_ context.Context) (string, error)
- func (*UseCase) RefreshToken(ctx context.Context, user domain.User) (string, error)
- func (a *UseCase) Register(ctx context.Context, registerStruct domain.Register) (domain.User, error)
- func (a *UseCase) RegisterOauth(ctx context.Context, user domain.User) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComparePasswords ¶
ComparePasswords compares a hashed password with its possible plaintext equivalent.
password is the plaintext password to verify. hash is the bcrypt hashed password.
Returns true if the password matches, false if it does not. Returns nil on success, or an error on failure.
func GenerateEncryptedPassword ¶
GenerateEncryptedPassword generates a password hash using the crypto helper.
func VerifyPassword ¶
VerifyPassword verifies a password Returns an error if the password is invalid.
Types ¶
type IAuthRedisRepository ¶
type IAuthRedisRepository interface { HasState(ctx context.Context, state string) (bool, error) SetState(ctx context.Context, state string) error DeleteState(ctx context.Context, state string) error }
IAuthRedisRepository is the interface for the auth redis repository.
func NewRedisRepository ¶
func NewRedisRepository(redisConn *redis.Client) IAuthRedisRepository
NewRedisRepository returns a new redis repository.
type IUseCase ¶
type IUseCase interface { Login(ctx context.Context, password string, email string) (string, error) Register(ctx context.Context, registerStruct domain.Register) (domain.User, error) Logout(ctx context.Context) (string, error) RefreshToken(ctx context.Context, user domain.User) (string, error) RegisterOauth(ctx context.Context, user domain.User) error LoginOauth(ctx context.Context, user domain.User) (string, error) }
IUseCase is the interface for the auth use case.
func NewUseCase ¶
func NewUseCase(repo user.IRepository) IUseCase
NewUseCase creates a new auth use case.
type RedisRepository ¶
type RedisRepository struct {
RedisConn *redis.Client
}
RedisRepository is the redis repository for the auth use case.
func (*RedisRepository) DeleteState ¶
func (r *RedisRepository) DeleteState(ctx context.Context, state string) error
DeleteState deletes the state in the redis database.
type UseCase ¶
type UseCase struct {
user.IRepository
}
UseCase is the auth use case.
func (*UseCase) LoginOauth ¶
func (*UseCase) Logout ¶
Logout returns an empty string It might be used to invalidate a token in the future.
func (*UseCase) RefreshToken ¶
RefreshToken refreshes a token.