add missing path property handling

This commit is contained in:
Jeffrey Duroyon
2020-05-18 00:56:43 +02:00
parent ca8e42388b
commit f6e0a826a1
21 changed files with 292 additions and 114 deletions

View File

@@ -43,7 +43,7 @@ func (hc *handlersContext) connectUser(c *gin.Context) {
utils.JSONError(c.Writer, model.ErrBadRequestFormat)
return
}
user, err := hc.userService.GetUserFromGoogleId(tokenInfo.UserId)
user, err := hc.userService.GetUserFromGoogleID(tokenInfo.UserId)
if err != nil {
utils.GetLogger().WithError(err).Error(err)
if castedError, ok := err.(*model.APIError); ok {
@@ -92,7 +92,7 @@ func (hc *handlersContext) createUser(c *gin.Context) {
}
err = hc.db.CreateUser(&user)
if e, ok := err.(*dao.DAOError); ok {
if e, ok := err.(*dao.Error); ok {
switch {
case e.Type == dao.ErrTypeDuplicate:
utils.JSONErrorWithMessage(c.Writer, model.ErrAlreadyExists, "User already exists")
@@ -121,7 +121,7 @@ func (hc *handlersContext) getUser(c *gin.Context) {
}
user, err := hc.db.GetUsersByID(userID)
if e, ok := err.(*dao.DAOError); ok {
if e, ok := err.(*dao.Error); ok {
switch {
case e.Type == dao.ErrTypeNotFound:
utils.JSONErrorWithMessage(c.Writer, model.ErrNotFound, "User not found")
@@ -156,7 +156,7 @@ func (hc *handlersContext) deleteUser(c *gin.Context) {
// check user id given in URL exists
_, err = hc.db.GetUsersByID(userID)
if e, ok := err.(*dao.DAOError); ok {
if e, ok := err.(*dao.Error); ok {
switch {
case e.Type == dao.ErrTypeNotFound:
utils.JSONErrorWithMessage(c.Writer, model.ErrNotFound, "User to delete not found")
@@ -173,7 +173,7 @@ func (hc *handlersContext) deleteUser(c *gin.Context) {
}
err = hc.db.DeleteUser(userID)
if e, ok := err.(*dao.DAOError); ok {
if e, ok := err.(*dao.Error); ok {
switch {
case e.Type == dao.ErrTypeNotFound:
utils.JSONErrorWithMessage(c.Writer, model.ErrNotFound, "User to delete not found")
@@ -203,7 +203,7 @@ func (hc *handlersContext) updateUser(c *gin.Context) {
// check user id given in URL exists
user, err := hc.db.GetUsersByID(userID)
if e, ok := err.(*dao.DAOError); ok {
if e, ok := err.(*dao.Error); ok {
switch {
case e.Type == dao.ErrTypeNotFound:
utils.JSONErrorWithMessage(c.Writer, model.ErrNotFound, "User to update not found")
@@ -244,7 +244,7 @@ func (hc *handlersContext) updateUser(c *gin.Context) {
// make the update
err = hc.db.UpdateUser(user)
if e, ok := err.(*dao.DAOError); ok {
if e, ok := err.(*dao.Error); ok {
switch {
case e.Type == dao.ErrTypeNotFound:
utils.JSONErrorWithMessage(c.Writer, model.ErrNotFound, "User to update not found")