mirror of
https://github.com/wisplite/raster.git
synced 2026-05-01 06:32:44 -05:00
a commit that changes nothing?
This commit is contained in:
@@ -1,32 +1,32 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/wisplite/raster/internal/services"
|
||||
)
|
||||
|
||||
func RegisterUserRoutes(rg *gin.RouterGroup) {
|
||||
user := rg.Group("/user")
|
||||
user.POST("/createUser", func(c *gin.Context) {
|
||||
username := c.PostForm("username")
|
||||
password := c.PostForm("password")
|
||||
err := services.CreateUser(username, password)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": "User created successfully"})
|
||||
})
|
||||
user.POST("/login", func(c *gin.Context) {
|
||||
username := c.PostForm("username")
|
||||
password := c.PostForm("password")
|
||||
accessToken, err := services.Login(username, password)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Login successful", "accessToken": accessToken.Token})
|
||||
})
|
||||
}
|
||||
package routes
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/wisplite/raster/internal/services"
|
||||
)
|
||||
|
||||
func RegisterUserRoutes(rg *gin.RouterGroup) {
|
||||
user := rg.Group("/user")
|
||||
user.POST("/createUser", func(c *gin.Context) {
|
||||
username := c.PostForm("username")
|
||||
password := c.PostForm("password")
|
||||
err := services.CreateUser(username, password)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": "User created successfully"})
|
||||
})
|
||||
user.POST("/login", func(c *gin.Context) {
|
||||
username := c.PostForm("username")
|
||||
password := c.PostForm("password")
|
||||
accessToken, err := services.Login(username, password)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Login successful", "accessToken": accessToken.Token})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user