-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.go
31 lines (26 loc) · 844 Bytes
/
login.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2023 m01i0ng <alley.ma@qq.com>. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file. The original repo for
// this file is https://github.com/m01i0ng/mblog.
package user
import (
"github.com/gin-gonic/gin"
"github.com/m01i0ng/mblog/internal/pkg/core"
"github.com/m01i0ng/mblog/internal/pkg/errno"
"github.com/m01i0ng/mblog/internal/pkg/log"
v1 "github.com/m01i0ng/mblog/pkg/api/mblog/v1"
)
func (uc *UserController) Login(c *gin.Context) {
log.C(c).Infow("Login func called")
var r v1.LoginRequest
if err := c.ShouldBindJSON(&r); err != nil {
core.WriteResponse(c, errno.ErrBind, nil)
return
}
response, err := uc.b.Users().Login(c, &r)
if err != nil {
core.WriteResponse(c, err, nil)
return
}
core.WriteResponse(c, nil, response)
}