diff --git a/api/auth.go b/api/auth.go index 2e422d5..8fa3551 100644 --- a/api/auth.go +++ b/api/auth.go @@ -38,6 +38,7 @@ func register(c *gin.Context) { }) return } + authController, err := controller.MakeAuthController() if err != nil { @@ -49,8 +50,9 @@ func register(c *gin.Context) { err = authController.Register(transaction.Username, transaction.Password, transaction.RepeatPassword) + // TODO: handle server errors/register violations separetly if err != nil { - c.JSON(http.StatusBadRequest, gin.H{ + c.JSON(http.StatusOK, gin.H{ "error": err.Error(), }) return @@ -84,14 +86,14 @@ func login(c *gin.Context) { token, ok, err := authController.Login(transaction.Username, transaction.Password) if err != nil { - c.JSON(http.StatusInternalServerError, gin.H{ + c.JSON(http.StatusOK, gin.H{ "error": err.Error(), }) return } if !ok { - c.JSON(http.StatusUnauthorized, gin.H{ + c.JSON(http.StatusOK, gin.H{ "error": "bad credentials", }) return