Cloudreve/routers/controllers/user.go
2019-11-12 15:34:54 +08:00

27 lines
514 B
Go

package controllers
import (
"cloudreve/pkg/serializer"
"cloudreve/service/user"
"github.com/gin-gonic/gin"
)
// UserLogin 用户登录
func UserLogin(c *gin.Context) {
var service user.UserLoginService
if err := c.ShouldBindJSON(&service); err == nil {
res := service.Login(c)
c.JSON(200, res)
} else {
c.JSON(200, ErrorResponse(err))
}
}
// UserMe 获取当前登录的用户
func UserMe(c *gin.Context) {
user := CurrentUser(c)
res := serializer.BuildUserResponse(*user)
c.JSON(200, res)
}