Skip to content

Commit

Permalink
Merge pull request #2 from daystram/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
daystram authored Jan 24, 2021
2 parents 07ae6bc + 5c88bfb commit aa0272f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion controllers/v1/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ func POSTRegister(c *gin.Context) {
c.JSON(http.StatusUnauthorized, datatransfers.Response{Error: "failed registering user"})
return
}
c.JSON(http.StatusOK, datatransfers.Response{Data: "user created"})
c.JSON(http.StatusCreated, datatransfers.Response{Data: "user created"})
return
}
6 changes: 3 additions & 3 deletions controllers/v1/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func GETUser(c *gin.Context) {
}
var user models.User
if user, err = handlers.Handler.RetrieveUser(userInfo.Username); err != nil {
c.JSON(http.StatusUnauthorized, datatransfers.Response{Error: "cannot find user"})
c.JSON(http.StatusNotFound, datatransfers.Response{Error: "cannot find user"})
return
}
c.JSON(http.StatusOK, datatransfers.Response{Data: datatransfers.UserInfo{
Expand All @@ -40,9 +40,9 @@ func PUTUser(c *gin.Context) {
return
}
if err = handlers.Handler.UpdateUser(uint(c.GetInt(constants.IsAuthenticatedKey)), user); err != nil {
c.JSON(http.StatusBadRequest, datatransfers.Response{Error: "failed updating user"})
c.JSON(http.StatusNotModified, datatransfers.Response{Error: "failed updating user"})
return
}
c.JSON(http.StatusOK, datatransfers.Response{Data: "OK"})
c.JSON(http.StatusOK, datatransfers.Response{Data: user})
return
}
2 changes: 1 addition & 1 deletion datatransfers/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

type JWTClaims struct {
ID uint `json:"id,omitempty"`
ID uint `json:"sub,omitempty"`
ExpiresAt int64 `json:"exp,omitempty"`
IssuedAt int64 `json:"iat,omitempty"`
}
Expand Down
2 changes: 1 addition & 1 deletion handlers/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func InitializeHandler() {
// Initialize DB
var db *gorm.DB
db, err = gorm.Open(postgres.Open(
fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=disable",
fmt.Sprintf("host=%s port=%d dbname=%s user=%s password=%s sslmode=disable",
config.AppConfig.DBHostname, config.AppConfig.DBPort, config.AppConfig.DBDatabase,
config.AppConfig.DBUsername, config.AppConfig.DBPassword),
), &gorm.Config{})
Expand Down

0 comments on commit aa0272f

Please sign in to comment.