|
@@ -161,13 +161,7 @@ func (l *Login) Login() error {
|
|
|
if phone == "" || l.GetSession("identCodeValue") == nil || l.GetString("identCode") != l.GetSession("identCodeValue") { //验证码不正确
|
|
|
return -1
|
|
|
} else {
|
|
|
- query := map[string]interface{}{
|
|
|
- "i_appid": 2,
|
|
|
- "$or": []map[string]interface{}{
|
|
|
- map[string]interface{}{"s_phone": phone},
|
|
|
- map[string]interface{}{"s_m_phone": phone}},
|
|
|
- }
|
|
|
- user, ok := mongodb.FindOne("user", query)
|
|
|
+ ok, user := getPhoneUser(phone)
|
|
|
//登录成功
|
|
|
if !ok {
|
|
|
return 0
|
|
@@ -178,7 +172,7 @@ func (l *Login) Login() error {
|
|
|
phoneType := l.GetString("phoneType")
|
|
|
channel := l.GetString("channel")
|
|
|
deviceId := l.GetString("deviceId")
|
|
|
- if user == nil || len(*user) == 0 {
|
|
|
+ if user == nil || len(user) == 0 {
|
|
|
//clearRidByRid(rid)
|
|
|
data := map[string]interface{}{
|
|
|
"i_appid": 2,
|
|
@@ -204,7 +198,7 @@ func (l *Login) Login() error {
|
|
|
}
|
|
|
} else {
|
|
|
jy.ClearPhoneIdentSession(l.Session())
|
|
|
- returnSign = afterLogin(*user, l.Session(), rid, oid, phoneType, channel, deviceId, 1, false)
|
|
|
+ returnSign = afterLogin(user, l.Session(), rid, oid, phoneType, channel, deviceId, 1, false)
|
|
|
return 1
|
|
|
}
|
|
|
}
|
|
@@ -604,7 +598,12 @@ func (l *Login) ForgetPwd() error {
|
|
|
return "codeError"
|
|
|
}
|
|
|
//手机号是否已被注册
|
|
|
- if !userIsExists(phone) {
|
|
|
+ if mongodb.Count("user", map[string]interface{}{
|
|
|
+ "i_appid": 2,
|
|
|
+ "$or": []map[string]interface{}{
|
|
|
+ map[string]interface{}{"s_phone": phone},
|
|
|
+ map[string]interface{}{"s_m_phone": phone}},
|
|
|
+ }) == 0 {
|
|
|
return "phoneNotExists"
|
|
|
} else if jy.SendPhoneIdentCode(phone, l.Session()) {
|
|
|
return "y"
|
|
@@ -624,14 +623,21 @@ func (l *Login) ForgetPwd() error {
|
|
|
if !passwordReg.MatchString(password) {
|
|
|
return "passwordError"
|
|
|
}
|
|
|
- if !userIsExists(phone) { //用户已存在
|
|
|
+ ok, user := getPhoneUser(phone)
|
|
|
+ if !ok || user == nil || len(user) == 0 { //用户不存在
|
|
|
return "userNotExists"
|
|
|
}
|
|
|
- query := map[string]interface{}{
|
|
|
- "i_appid": 2,
|
|
|
- "s_phone": phone,
|
|
|
- }
|
|
|
- if mongodb.Update("user", query, map[string]interface{}{"$set": map[string]interface{}{"s_password": qutil.GetMd5String(password), "l_updatepwdtime": time.Now().Unix()}}, false, false) {
|
|
|
+ if mongodb.Update("user", map[string]interface{}{
|
|
|
+ "_id": user["_id"],
|
|
|
+ }, map[string]interface{}{
|
|
|
+ "$set": map[string]interface{}{
|
|
|
+ "s_phone": phone,
|
|
|
+ "s_password": qutil.GetMd5String(password),
|
|
|
+ "l_updatepwdtime": time.Now().Unix(),
|
|
|
+ },
|
|
|
+ "$unset": map[string]interface{}{
|
|
|
+ "s_m_phone": "",
|
|
|
+ }}, false, false) {
|
|
|
l.DelSession("forgetPwdStep")
|
|
|
jy.ClearPhoneIdentSession(l.Session())
|
|
|
return "y"
|
|
@@ -756,6 +762,18 @@ func (l *Login) Brand() {
|
|
|
/**********************************************************************
|
|
|
***********************************************************************
|
|
|
***********************************************************************/
|
|
|
+func getPhoneUser(phone string) (bool, map[string]interface{}) {
|
|
|
+ users, ok := mongodb.Find("user", map[string]interface{}{
|
|
|
+ "i_appid": 2,
|
|
|
+ "$or": []map[string]interface{}{
|
|
|
+ map[string]interface{}{"s_phone": phone},
|
|
|
+ map[string]interface{}{"s_m_phone": phone}},
|
|
|
+ }, `{"s_phone":-1}`, nil, false, 0, 1)
|
|
|
+ if users != nil && len(*users) > 0 {
|
|
|
+ return ok, (*users)[0]
|
|
|
+ }
|
|
|
+ return ok, nil
|
|
|
+}
|
|
|
|
|
|
//手机号用户是否存在
|
|
|
func userIsExists(phoneNum string) bool {
|