feat: allow user to login with username and mobile no

This commit is contained in:
RockYang
2023-07-27 15:37:50 +08:00
parent 4a3c133152
commit a32cb0142b
6 changed files with 15 additions and 6 deletions

View File

@@ -143,7 +143,7 @@ func (h *UserHandler) Login(c *gin.Context) {
return
}
var user model.User
res := h.db.Where("username = ?", data.Username).First(&user)
res := h.db.Where("username = ? OR mobile = ?", data.Username, data.Username).First(&user)
if res.Error != nil {
resp.ERROR(c, "用户名不存在")
return