mirror of
				https://github.com/yangjian102621/geekai.git
				synced 2025-11-04 08:13:43 +08:00 
			
		
		
		
	feat: allow user to login with username and mobile no
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -35,9 +35,12 @@ func (f FuncHeadlines) Invoke(...interface{}) (string, error) {
 | 
			
		||||
		SetHeader("AppId", f.config.AppId).
 | 
			
		||||
		SetHeader("Authorization", fmt.Sprintf("Bearer %s", f.config.Token)).
 | 
			
		||||
		SetSuccessResult(&res).Get(url)
 | 
			
		||||
	if err != nil || r.IsErrorState() {
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	if r.IsErrorState() {
 | 
			
		||||
		return "", r.Err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if res.Code != types.Success {
 | 
			
		||||
		return "", errors.New(res.Message)
 | 
			
		||||
 
 | 
			
		||||
@@ -35,9 +35,12 @@ func (f FuncWeiboHot) Invoke(...interface{}) (string, error) {
 | 
			
		||||
		SetHeader("AppId", f.config.AppId).
 | 
			
		||||
		SetHeader("Authorization", fmt.Sprintf("Bearer %s", f.config.Token)).
 | 
			
		||||
		SetSuccessResult(&res).Get(url)
 | 
			
		||||
	if err != nil || r.IsErrorState() {
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	if r.IsErrorState() {
 | 
			
		||||
		return "", r.Err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if res.Code != types.Success {
 | 
			
		||||
		return "", errors.New(res.Message)
 | 
			
		||||
 
 | 
			
		||||
@@ -35,9 +35,12 @@ func (f FuncZaoBao) Invoke(...interface{}) (string, error) {
 | 
			
		||||
		SetHeader("AppId", f.config.AppId).
 | 
			
		||||
		SetHeader("Authorization", fmt.Sprintf("Bearer %s", f.config.Token)).
 | 
			
		||||
		SetSuccessResult(&res).Get(url)
 | 
			
		||||
	if err != nil || r.IsErrorState() {
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return "", err
 | 
			
		||||
	}
 | 
			
		||||
	if r.IsErrorState() {
 | 
			
		||||
		return "", r.Err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if res.Code != types.Success {
 | 
			
		||||
		return "", errors.New(res.Message)
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,7 @@ services:
 | 
			
		||||
    ports:
 | 
			
		||||
      - "6789:5678"
 | 
			
		||||
    volumes:
 | 
			
		||||
      - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime
 | 
			
		||||
      - ./conf/config.toml:/var/www/app/config.toml
 | 
			
		||||
      - ./static:/var/www/app/static
 | 
			
		||||
 | 
			
		||||
@@ -22,7 +23,6 @@ services:
 | 
			
		||||
    ports:
 | 
			
		||||
      - "8080:8080"
 | 
			
		||||
    volumes:
 | 
			
		||||
      - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime
 | 
			
		||||
      - ./logs/nginx:/var/log/nginx
 | 
			
		||||
      - ./conf/nginx/conf.d:/etc/nginx/conf.d
 | 
			
		||||
      - ./conf/nginx/nginx.conf:/etc/nginx/nginx.conf
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
        <div class="header">{{ title }}</div>
 | 
			
		||||
        <div class="content">
 | 
			
		||||
          <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>
 | 
			
		||||
                <el-icon>
 | 
			
		||||
                  <UserFilled/>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user