mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-18 01:06:39 +08:00
feat: allow user to login with username and mobile no
This commit is contained in:
parent
4faee3e48e
commit
a18188876c
@ -143,7 +143,7 @@ func (h *UserHandler) Login(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
var user model.User
|
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 {
|
if res.Error != nil {
|
||||||
resp.ERROR(c, "用户名不存在")
|
resp.ERROR(c, "用户名不存在")
|
||||||
return
|
return
|
||||||
|
@ -35,9 +35,12 @@ func (f FuncHeadlines) Invoke(...interface{}) (string, error) {
|
|||||||
SetHeader("AppId", f.config.AppId).
|
SetHeader("AppId", f.config.AppId).
|
||||||
SetHeader("Authorization", fmt.Sprintf("Bearer %s", f.config.Token)).
|
SetHeader("Authorization", fmt.Sprintf("Bearer %s", f.config.Token)).
|
||||||
SetSuccessResult(&res).Get(url)
|
SetSuccessResult(&res).Get(url)
|
||||||
if err != nil || r.IsErrorState() {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
if r.IsErrorState() {
|
||||||
|
return "", r.Err
|
||||||
|
}
|
||||||
|
|
||||||
if res.Code != types.Success {
|
if res.Code != types.Success {
|
||||||
return "", errors.New(res.Message)
|
return "", errors.New(res.Message)
|
||||||
|
@ -35,9 +35,12 @@ func (f FuncWeiboHot) Invoke(...interface{}) (string, error) {
|
|||||||
SetHeader("AppId", f.config.AppId).
|
SetHeader("AppId", f.config.AppId).
|
||||||
SetHeader("Authorization", fmt.Sprintf("Bearer %s", f.config.Token)).
|
SetHeader("Authorization", fmt.Sprintf("Bearer %s", f.config.Token)).
|
||||||
SetSuccessResult(&res).Get(url)
|
SetSuccessResult(&res).Get(url)
|
||||||
if err != nil || r.IsErrorState() {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
if r.IsErrorState() {
|
||||||
|
return "", r.Err
|
||||||
|
}
|
||||||
|
|
||||||
if res.Code != types.Success {
|
if res.Code != types.Success {
|
||||||
return "", errors.New(res.Message)
|
return "", errors.New(res.Message)
|
||||||
|
@ -35,9 +35,12 @@ func (f FuncZaoBao) Invoke(...interface{}) (string, error) {
|
|||||||
SetHeader("AppId", f.config.AppId).
|
SetHeader("AppId", f.config.AppId).
|
||||||
SetHeader("Authorization", fmt.Sprintf("Bearer %s", f.config.Token)).
|
SetHeader("Authorization", fmt.Sprintf("Bearer %s", f.config.Token)).
|
||||||
SetSuccessResult(&res).Get(url)
|
SetSuccessResult(&res).Get(url)
|
||||||
if err != nil || r.IsErrorState() {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
if r.IsErrorState() {
|
||||||
|
return "", r.Err
|
||||||
|
}
|
||||||
|
|
||||||
if res.Code != types.Success {
|
if res.Code != types.Success {
|
||||||
return "", errors.New(res.Message)
|
return "", errors.New(res.Message)
|
||||||
|
@ -11,6 +11,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "6789:5678"
|
- "6789:5678"
|
||||||
volumes:
|
volumes:
|
||||||
|
- /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime
|
||||||
- ./conf/config.toml:/var/www/app/config.toml
|
- ./conf/config.toml:/var/www/app/config.toml
|
||||||
- ./static:/var/www/app/static
|
- ./static:/var/www/app/static
|
||||||
|
|
||||||
@ -22,7 +23,6 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
volumes:
|
volumes:
|
||||||
- /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime
|
|
||||||
- ./logs/nginx:/var/log/nginx
|
- ./logs/nginx:/var/log/nginx
|
||||||
- ./conf/nginx/conf.d:/etc/nginx/conf.d
|
- ./conf/nginx/conf.d:/etc/nginx/conf.d
|
||||||
- ./conf/nginx/nginx.conf:/etc/nginx/nginx.conf
|
- ./conf/nginx/nginx.conf:/etc/nginx/nginx.conf
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<div class="header">{{ title }}</div>
|
<div class="header">{{ title }}</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<el-input placeholder="手机号/邮箱" size="large" v-model="username" autocomplete="off">
|
<el-input placeholder="手机号/用户名" size="large" v-model="username" autocomplete="off">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<el-icon>
|
<el-icon>
|
||||||
<UserFilled/>
|
<UserFilled/>
|
||||||
|
Loading…
Reference in New Issue
Block a user