fixes on structuring

This commit is contained in:
Fran Jurmanović
2021-05-15 22:23:30 +02:00
parent e7a80796f7
commit cc98d0cf49
10 changed files with 125 additions and 60 deletions

View File

@@ -22,15 +22,15 @@ func NewLoginController(rs *services.UsersService, s *gin.RouterGroup) *LoginCon
}
func (rc *LoginController) Post(c *gin.Context) {
loginBody := new(models.LoginModel)
if err := c.ShouldBindJSON(&loginBody); err != nil {
body := new(models.LoginModel)
if err := c.ShouldBindJSON(&body); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
returnedUser, returnException := rc.UsersService.Login(loginBody)
returnedUser, exceptionReturn := rc.UsersService.Login(body)
if returnException.Message != "" {
c.JSON(returnException.StatusCode, returnException)
if exceptionReturn.Message != "" {
c.JSON(exceptionReturn.StatusCode, exceptionReturn)
} else {
c.JSON(200, returnedUser)
}