service

package
v0.0.0-...-c91a537 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmailAlreadyExists  = status.Error(codes.AlreadyExists, "a user with this email already exists")
	ErrEmailInvalid        = status.Error(codes.InvalidArgument, "invalid email format")
	ErrInvalidCredentials  = status.Error(codes.InvalidArgument, "invalid credentials")
	ErrPasswordRequired    = status.Error(codes.InvalidArgument, "password is required")
	ErrTokenInvalid        = status.Error(codes.InvalidArgument, "invalid token")
	ErrTokenRequired       = status.Error(codes.InvalidArgument, "token is required")
	ErrUserAlreadyVerified = status.Error(codes.FailedPrecondition, "user is already verified")
	ErrUserNotFound        = status.Error(codes.NotFound, "user not found")
)

Functions

func ErrInternal

func ErrInternal(err error) error

func ErrInvalidArgument

func ErrInvalidArgument(err error) error

Types

type AuthService

type AuthService struct {
	pb.UnimplementedAuthenticationServer
	UserRepo  *repos.UserRepository
	TokenRepo *repos.TokenRepository
}

func (*AuthService) BearerToken

BearerToken generates a bearer token for a user, based on their provided credentials. It takes in a context and a BearerTokenRequest, and returns a BearerTokenResponse and an error.

func (*AuthService) Register

Register creates a new user account based on the provided registration details. It takes in a context and a RegisterRequest, and returns a UserResponse and an error.

func (*AuthService) ResetPassword

func (s *AuthService) ResetPassword(_ context.Context, in *pb.ResetPasswordRequest) (*pb.Empty, error)

ResetPassword resets a user's password, given the provided reset password details. It takes in a context and a ResetPasswordRequest, and returns an Empty response and an error.

func (*AuthService) ResetPasswordToken

func (s *AuthService) ResetPasswordToken(_ context.Context, in *pb.ResetPasswordTokenRequest) (*pb.TokenWithEmail, error)

ResetPasswordToken generates a reset password token for a user based on their email. It takes in a context and a ResetPasswordTokenRequest, and returns a TokenWithEmail and an error.

func (*AuthService) RevokeBearerToken

func (s *AuthService) RevokeBearerToken(_ context.Context, in *pb.Token) (*pb.Empty, error)

RevokeBearerToken revokes a user's bearer token. It takes in a context and a Token, and returns an Empty response and an error.

func (*AuthService) UpdateUser

func (s *AuthService) UpdateUser(_ context.Context, in *pb.UpdateUserRequest) (*pb.UserResponse, error)

UpdateUser updates a user based on the provided bearer token. It takes in a context and a UpdateUserRequest, and returns a UserResponse and an error.

func (*AuthService) User

func (s *AuthService) User(_ context.Context, in *pb.Token) (*pb.UserResponse, error)

User retrieves user details based on the provided token. It takes in a context and a Token, and returns a UserResponse and an error.

func (*AuthService) VerifyUser

func (s *AuthService) VerifyUser(_ context.Context, in *pb.Token) (*pb.UserResponse, error)

VerifyUser verifies a user's account, given the provided token. It takes in a context and a Token, and returns a UserResponse and an error.

func (*AuthService) VerifyUserToken

func (s *AuthService) VerifyUserToken(_ context.Context, in *pb.VerifyUserTokenRequest) (*pb.TokenWithEmail, error)

VerifyUserToken generates a user verification token based on their email. It takes in a context and a VerifyUserTokenRequest, and returns a TokenWithEmail and an error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL