feat: service/controller prototype
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"easywish/internal/models"
|
||||
"easywish/internal/services"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -28,9 +30,28 @@ func RegistrationComplete(c *gin.Context) {
|
||||
// @Tags Auth
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param request body models.LoginRequest true "desc"
|
||||
// @Success 200 {object} models.LoginResponse "desc"
|
||||
// @Router /auth/login [post]
|
||||
func Login(c *gin.Context) {
|
||||
c.Status(http.StatusNotImplemented)
|
||||
|
||||
var request models.LoginRequest
|
||||
|
||||
if err := c.ShouldBindJSON(&request); err != nil {
|
||||
c.Status(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
auths := services.NewAuthService()
|
||||
|
||||
result, err := auths.Login(request)
|
||||
|
||||
if err != nil {
|
||||
c.Status(http.StatusTeapot)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusFound, result)
|
||||
}
|
||||
|
||||
// @Summary Receive new tokens via refresh token
|
||||
|
||||
Reference in New Issue
Block a user