Documentation ¶
Index ¶
- type AuthHandler
- func (authHandler *AuthHandler) CheckAuth(writer http.ResponseWriter, request *http.Request)
- func (authHandler *AuthHandler) EditUserEmail(writer http.ResponseWriter, request *http.Request)
- func (authHandler *AuthHandler) GetCSRFToken(writer http.ResponseWriter, request *http.Request)
- func (authHandler *AuthHandler) Login(writer http.ResponseWriter, request *http.Request)
- func (authHandler *AuthHandler) Logout(writer http.ResponseWriter, request *http.Request)
- func (authHandler *AuthHandler) Signup(writer http.ResponseWriter, request *http.Request)
- type AuthManager
- func (manager *AuthManager) EditEmail(ctx context.Context, in *protobuf.EditEmailRequest) (*protobuf.User, error)
- func (manager *AuthManager) GetCurrentUser(ctx context.Context, in *protobuf.SessionData) (*protobuf.AuthUser, error)
- func (manager *AuthManager) Login(ctx context.Context, in *protobuf.ExistedUserData) (*protobuf.LoggedUser, error)
- func (manager *AuthManager) Logout(ctx context.Context, in *protobuf.SessionData) (*emptypb.Empty, error)
- func (manager *AuthManager) Signup(ctx context.Context, in *protobuf.NewUserData) (*protobuf.LoggedUser, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
func NewAuthHandler ¶
func NewAuthHandler(authClient authproto.AuthClient, profileClient profileproto.ProfileClient) *AuthHandler
func (*AuthHandler) CheckAuth ¶
func (authHandler *AuthHandler) CheckAuth(writer http.ResponseWriter, request *http.Request)
CheckAuth godoc @Summary Check user authentication @Description Verify if the user is authenticated by checking the session @Tags auth @Accept json @Produce json @Success 200 {object} responses.AuthOkResponse @Router /api/auth/check_auth [get]
func (*AuthHandler) EditUserEmail ¶
func (authHandler *AuthHandler) EditUserEmail(writer http.ResponseWriter, request *http.Request)
func (*AuthHandler) GetCSRFToken ¶
func (authHandler *AuthHandler) GetCSRFToken(writer http.ResponseWriter, request *http.Request)
func (*AuthHandler) Login ¶
func (authHandler *AuthHandler) Login(writer http.ResponseWriter, request *http.Request)
Login godoc @Summary User login @Description Authenticate user and create a new session @Tags auth @Accept json @Produce json @Param email formData string true "User email" @Param password formData string true "User password" @Success 200 {object} responses.AuthOkResponse @Failure 400 {object} responses.AuthErrResponse "Bad request" @Failure 401 {object} responses.AuthErrResponse "Unauthorized" @Failure 405 {object} responses.AuthErrResponse "Method not allowed" @Failure 500 {object} responses.AuthErrResponse "Internal server error" @Router /api/auth/login [post]
func (*AuthHandler) Logout ¶
func (authHandler *AuthHandler) Logout(writer http.ResponseWriter, request *http.Request)
Logout godoc @Summary User logout @Description Invalidate the user session and log the user out @Tags auth @Accept json @Produce json @Success 200 @Failure 400 {object} responses.AuthErrResponse "Bad request" @Failure 401 {object} responses.AuthErrResponse "User not authorized" @Failure 405 {object} responses.AuthErrResponse "Method not allowed" @Failure 500 {object} responses.AuthErrResponse "Internal server error" @Router /api/auth/logout [post]
func (*AuthHandler) Signup ¶
func (authHandler *AuthHandler) Signup(writer http.ResponseWriter, request *http.Request)
Signup godoc @Summary User signup @Description Register a new user and create a new session @Tags auth @Accept json @Produce json @Param email formData string true "User email" @Param password formData string true "User password" @Param passwordRepeat formData string true "Password confirmation" @Success 201 {object} responses.AuthOkResponse @Failure 400 {object} responses.AuthErrResponse @Router /api/auth/signup [post]
type AuthManager ¶
type AuthManager struct { protobuf.UnimplementedAuthServer // contains filtered or unexported fields }
func NewAuthManager ¶
func NewAuthManager(storage userusecases.UsersStorageInterface) *AuthManager
func (*AuthManager) EditEmail ¶
func (manager *AuthManager) EditEmail(ctx context.Context, in *protobuf.EditEmailRequest) (*protobuf.User, error)
func (*AuthManager) GetCurrentUser ¶
func (manager *AuthManager) GetCurrentUser(ctx context.Context, in *protobuf.SessionData) (*protobuf.AuthUser, error)
func (*AuthManager) Login ¶
func (manager *AuthManager) Login(ctx context.Context, in *protobuf.ExistedUserData) (*protobuf.LoggedUser, error)
func (*AuthManager) Logout ¶
func (manager *AuthManager) Logout(ctx context.Context, in *protobuf.SessionData) (*emptypb.Empty, error)
func (*AuthManager) Signup ¶
func (manager *AuthManager) Signup(ctx context.Context, in *protobuf.NewUserData) (*protobuf.LoggedUser, error)