Esempio n. 1
0
func Login(context echo.Context) error {
	_, err := helpers.ValidateJWT(context)
	if err != nil {
		return context.Render(http.StatusOK, "login", os.Getenv("AUTH0_CALLBACK"))
	}

	context.Redirect(http.StatusMovedPermanently, "/frontend")

	return context.String(http.StatusOK, "Done")
}
Esempio n. 2
0
func (handlerGroup *HandlerGroup) GetBucket(context echo.Context) error {
	token, err := helpers.ValidateJWT(context)
	if err != nil {
		return context.String(http.StatusBadRequest, err.Error())
	}

	response, err := handlerGroup.Accessors.GetBucket(context, token.Email)
	if err != nil {
		return context.String(http.StatusBadRequest, err.Error())
	}

	return context.JSON(http.StatusOK, response)
}
Esempio n. 3
0
func (handlerGroup *HandlerGroup) GetUserByID(context echo.Context) error {
	_, err := helpers.ValidateJWT(context)
	if err != nil {
		return context.String(http.StatusBadRequest, err.Error())
	}

	response, err := handlerGroup.Accessors.GetUserByID(context.Param("id"))
	if err != nil {
		return context.String(http.StatusBadRequest, err.Error())
	}

	return context.JSON(http.StatusOK, response)
}
Esempio n. 4
0
func (handlerGroup *HandlerGroup) GetUserByEmail(context echo.Context) error {
	token, err := helpers.ValidateJWT(context)
	if err != nil {
		return context.String(http.StatusBadRequest, err.Error())
	}

	email := ""

	if len(context.Param("email")) > 0 {
		email = context.Param("email")
	} else {
		email = token.Email
	}

	response, err := handlerGroup.Accessors.GetUserByEmail(email)
	if err != nil {
		return context.String(http.StatusBadRequest, err.Error())
	}

	return context.JSON(http.StatusOK, response)
}