DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

cd256ffbb613db3b7cbcfe0aa62d8428fe9305df — Jonni Liljamo 2 years ago 2f16805
Change how user details are fetched
2 files changed, 4 insertions(+), 4 deletions(-)

M sdbapi/handlers/userinfo.go
M sdbapi/main.go
M sdbapi/handlers/userinfo.go => sdbapi/handlers/userinfo.go +2 -2
@@ 18,10 18,10 @@ import (
)

func UserInfo(c *gin.Context) {
	username := c.Param("username")
	id := c.Param("id")

	var user models.User
	record := db.DbConn.Where("username = ?", username).First(&user)
	record := db.DbConn.Where("id = ?", id).First(&user)
	if record.Error != nil {
		c.JSON(http.StatusNotFound, gin.H{"error": errors.UserNotFound})
		c.Abort()

M sdbapi/main.go => sdbapi/main.go +2 -2
@@ 39,10 39,10 @@ func createRouter() *gin.Engine {
		{
			user.POST("/register", handlers.CreateUser)
			user.POST("/token", handlers.GenerateToken)
			user.GET("/info/:username", handlers.UserInfo)
			user.GET("/:id", handlers.UserInfo)
			userp := user.Group("/_").Use(middlewares.Auth())
			{
				userp.GET("/info/:id", handlers.UserInfoP)
				userp.GET("/:id", handlers.UserInfoP)
			}
		}
	}