Documentation ¶
Index ¶
- Variables
- func ErrInternal(err error) error
- func ErrInvalidArgument(err error) error
- type AuthService
- func (s *AuthService) BearerToken(_ context.Context, in *pb.BearerTokenRequest) (*pb.BearerTokenResponse, error)
- func (s *AuthService) Register(_ context.Context, in *pb.RegisterRequest) (*pb.UserResponse, error)
- func (s *AuthService) ResetPassword(_ context.Context, in *pb.ResetPasswordRequest) (*pb.Empty, error)
- func (s *AuthService) ResetPasswordToken(_ context.Context, in *pb.ResetPasswordTokenRequest) (*pb.TokenWithEmail, error)
- func (s *AuthService) RevokeBearerToken(_ context.Context, in *pb.Token) (*pb.Empty, error)
- func (s *AuthService) UpdateUser(_ context.Context, in *pb.UpdateUserRequest) (*pb.UserResponse, error)
- func (s *AuthService) User(_ context.Context, in *pb.Token) (*pb.UserResponse, error)
- func (s *AuthService) VerifyUser(_ context.Context, in *pb.Token) (*pb.UserResponse, error)
- func (s *AuthService) VerifyUserToken(_ context.Context, in *pb.VerifyUserTokenRequest) (*pb.TokenWithEmail, error)
Constants ¶
This section is empty.
Variables ¶
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 ErrInvalidArgument ¶
Types ¶
type AuthService ¶
type AuthService struct { pb.UnimplementedAuthenticationServer UserRepo *repos.UserRepository TokenRepo *repos.TokenRepository }
func (*AuthService) BearerToken ¶
func (s *AuthService) BearerToken(_ context.Context, in *pb.BearerTokenRequest) (*pb.BearerTokenResponse, error)
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 ¶
func (s *AuthService) Register(_ context.Context, in *pb.RegisterRequest) (*pb.UserResponse, error)
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 ¶
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.