2022-09-11 21:59:13 -06:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/database"
|
|
|
|
"github.com/fastenhealth/fastenhealth-onprem/backend/pkg/models"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
func AuthSignup(c *gin.Context) {
|
|
|
|
databaseRepo := c.MustGet("REPOSITORY").(database.DatabaseRepository)
|
|
|
|
|
|
|
|
var user models.User
|
|
|
|
if err := c.ShouldBindJSON(&user); err != nil {
|
2022-10-08 20:40:33 -06:00
|
|
|
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error()})
|
2022-09-11 21:59:13 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
err := databaseRepo.CreateUser(c, &user)
|
|
|
|
if err != nil {
|
2022-10-08 20:40:33 -06:00
|
|
|
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": err.Error()})
|
2022-09-11 21:59:13 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-10-08 20:40:33 -06:00
|
|
|
c.JSON(http.StatusOK, gin.H{"success": true})
|
2022-09-11 21:59:13 -06:00
|
|
|
}
|