mirror of
				https://github.com/openimsdk/open-im-server.git
				synced 2025-11-04 19:32:17 +08:00 
			
		
		
		
	fix reset password api
This commit is contained in:
		
							parent
							
								
									e767f3f18f
								
							
						
					
					
						commit
						c76ecd48f1
					
				@ -21,7 +21,7 @@ type paramsVerificationCode struct {
 | 
				
			|||||||
	Email       string `json:"email"`
 | 
						Email       string `json:"email"`
 | 
				
			||||||
	PhoneNumber string `json:"phoneNumber"`
 | 
						PhoneNumber string `json:"phoneNumber"`
 | 
				
			||||||
	OperationID string `json:"operationID" binding:"required"`
 | 
						OperationID string `json:"operationID" binding:"required"`
 | 
				
			||||||
	UsedFor     int `json:"usedFor" binding:"required"`
 | 
						UsedFor     int `json:"usedFor"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func SendVerificationCode(c *gin.Context) {
 | 
					func SendVerificationCode(c *gin.Context) {
 | 
				
			||||||
@ -38,6 +38,9 @@ func SendVerificationCode(c *gin.Context) {
 | 
				
			|||||||
		account = params.PhoneNumber
 | 
							account = params.PhoneNumber
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	var accountKey string
 | 
						var accountKey string
 | 
				
			||||||
 | 
						if params.UsedFor == 0 {
 | 
				
			||||||
 | 
							params.UsedFor = constant.VerificationCodeForRegister
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	switch params.UsedFor {
 | 
						switch params.UsedFor {
 | 
				
			||||||
	case constant.VerificationCodeForRegister:
 | 
						case constant.VerificationCodeForRegister:
 | 
				
			||||||
		_, err := im_mysql_model.GetRegister(account)
 | 
							_, err := im_mysql_model.GetRegister(account)
 | 
				
			||||||
 | 
				
			|||||||
@ -15,7 +15,7 @@ type paramsCertification struct {
 | 
				
			|||||||
	PhoneNumber      string `json:"phoneNumber"`
 | 
						PhoneNumber      string `json:"phoneNumber"`
 | 
				
			||||||
	VerificationCode string `json:"verificationCode"`
 | 
						VerificationCode string `json:"verificationCode"`
 | 
				
			||||||
	OperationID      string `json:"operationID" binding:"required"`
 | 
						OperationID      string `json:"operationID" binding:"required"`
 | 
				
			||||||
	UsedFor          int `json:"usedFor" binding:"required"`
 | 
						UsedFor          int `json:"usedFor"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func Verify(c *gin.Context) {
 | 
					func Verify(c *gin.Context) {
 | 
				
			||||||
@ -44,8 +44,11 @@ func Verify(c *gin.Context) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	log.NewInfo("0", " params.VerificationCode != config.Config.Demo.SuperCode", params.VerificationCode, config.Config.Demo)
 | 
						log.NewInfo("0", " params.VerificationCode != config.Config.Demo.SuperCode", params.VerificationCode, config.Config.Demo)
 | 
				
			||||||
	log.NewInfo(params.OperationID, "begin get form redis", account)
 | 
						log.NewInfo(params.OperationID, "begin get form redis", account)
 | 
				
			||||||
 | 
						if params.UsedFor == 0 {
 | 
				
			||||||
	code, err := db.DB.GetAccountCode(account)
 | 
							params.UsedFor = 1
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						accountKey := account + "_" + constant.VerificationCodeForResetSuffix
 | 
				
			||||||
 | 
						code, err := db.DB.GetAccountCode(accountKey)
 | 
				
			||||||
	log.NewInfo(params.OperationID, "redis phone number and verificating Code", account, code)
 | 
						log.NewInfo(params.OperationID, "redis phone number and verificating Code", account, code)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		log.NewError(params.OperationID, "Verification code expired", account, "err", err.Error())
 | 
							log.NewError(params.OperationID, "Verification code expired", account, "err", err.Error())
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,6 @@ package db
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"Open_IM/pkg/common/constant"
 | 
						"Open_IM/pkg/common/constant"
 | 
				
			||||||
	log2 "Open_IM/pkg/common/log"
 | 
						log2 "Open_IM/pkg/common/log"
 | 
				
			||||||
	"fmt"
 | 
					 | 
				
			||||||
	"github.com/garyburd/redigo/redis"
 | 
						"github.com/garyburd/redigo/redis"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -47,7 +46,6 @@ func (d *DataBases) SetAccountCode(account string, code, ttl int) (err error) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
func (d *DataBases) GetAccountCode(account string) (string, error) {
 | 
					func (d *DataBases) GetAccountCode(account string) (string, error) {
 | 
				
			||||||
	key := AccountTempCode + account
 | 
						key := AccountTempCode + account
 | 
				
			||||||
	fmt.Println(key)
 | 
					 | 
				
			||||||
	return redis.String(d.Exec("GET", key))
 | 
						return redis.String(d.Exec("GET", key))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user