2019-11-05 19:49:56 +08:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import (
|
2019-11-16 16:11:37 +08:00
|
|
|
"github.com/HFO4/cloudreve/pkg/serializer"
|
|
|
|
"github.com/HFO4/cloudreve/service/user"
|
2019-11-05 19:49:56 +08:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
// UserLogin 用户登录
|
|
|
|
func UserLogin(c *gin.Context) {
|
2019-11-11 19:13:17 +08:00
|
|
|
var service user.UserLoginService
|
2019-11-05 19:49:56 +08:00
|
|
|
if err := c.ShouldBindJSON(&service); err == nil {
|
2019-11-06 16:42:13 +08:00
|
|
|
res := service.Login(c)
|
|
|
|
c.JSON(200, res)
|
2019-11-05 19:49:56 +08:00
|
|
|
} else {
|
|
|
|
c.JSON(200, ErrorResponse(err))
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-11-12 15:34:54 +08:00
|
|
|
|
|
|
|
// UserMe 获取当前登录的用户
|
|
|
|
func UserMe(c *gin.Context) {
|
|
|
|
user := CurrentUser(c)
|
|
|
|
res := serializer.BuildUserResponse(*user)
|
|
|
|
c.JSON(200, res)
|
|
|
|
|
|
|
|
}
|