mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
fix reset password api
This commit is contained in:
parent
c09ebc146b
commit
dfdb952e2b
@ -21,7 +21,7 @@ type paramsVerificationCode struct {
|
||||
Email string `json:"email"`
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UsedFor int `json:"usedFor" binding:"required"`
|
||||
UsedFor int `json:"usedFor"`
|
||||
}
|
||||
|
||||
func SendVerificationCode(c *gin.Context) {
|
||||
@ -38,6 +38,9 @@ func SendVerificationCode(c *gin.Context) {
|
||||
account = params.PhoneNumber
|
||||
}
|
||||
var accountKey string
|
||||
if params.UsedFor == 0 {
|
||||
params.UsedFor = constant.VerificationCodeForRegister
|
||||
}
|
||||
switch params.UsedFor {
|
||||
case constant.VerificationCodeForRegister:
|
||||
_, err := im_mysql_model.GetRegister(account)
|
||||
|
@ -15,7 +15,7 @@ type paramsCertification struct {
|
||||
PhoneNumber string `json:"phoneNumber"`
|
||||
VerificationCode string `json:"verificationCode"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UsedFor int `json:"usedFor" binding:"required"`
|
||||
UsedFor int `json:"usedFor"`
|
||||
}
|
||||
|
||||
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(params.OperationID, "begin get form redis", account)
|
||||
|
||||
code, err := db.DB.GetAccountCode(account)
|
||||
if params.UsedFor == 0 {
|
||||
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)
|
||||
if err != nil {
|
||||
log.NewError(params.OperationID, "Verification code expired", account, "err", err.Error())
|
||||
|
@ -3,7 +3,6 @@ package db
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
log2 "Open_IM/pkg/common/log"
|
||||
"fmt"
|
||||
"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) {
|
||||
key := AccountTempCode + account
|
||||
fmt.Println(key)
|
||||
return redis.String(d.Exec("GET", key))
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user