mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-02-06 14:18:12 +00:00
fixes on structuring
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user