group i18n, pwd 重置密码优化

This commit is contained in:
lealife
2015-11-28 14:28:51 +08:00
parent bba57ea302
commit 10f23c19ab
2 changed files with 10 additions and 8 deletions

View File

@ -185,16 +185,16 @@ func (this *GroupService) AddUser(ownUserId, groupId, userId string) (ok bool, m
// groupId是否是ownUserId的? // groupId是否是ownUserId的?
/* /*
if !this.IsExistsGroupUser(ownUserId, groupId) { if !this.IsExistsGroupUser(ownUserId, groupId) {
return false, "forbidden" return false, "forbiddenNotMyGroup"
} }
*/ */
if !this.isMyGroup(ownUserId, groupId) { if !this.isMyGroup(ownUserId, groupId) {
return false, "forbidden" return false, "forbiddenNotMyGroup"
} }
// 是否已存在 // 是否已存在
if db.Has(db.GroupUsers, bson.M{"GroupId": bson.ObjectIdHex(groupId), "UserId": bson.ObjectIdHex(userId)}) { if db.Has(db.GroupUsers, bson.M{"GroupId": bson.ObjectIdHex(groupId), "UserId": bson.ObjectIdHex(userId)}) {
return false, "hasUsers" return false, "userExistsInGroup"
} }
return db.Insert(db.GroupUsers, info.GroupUser{ return db.Insert(db.GroupUsers, info.GroupUser{
@ -210,11 +210,11 @@ func (this *GroupService) DeleteUser(ownUserId, groupId, userId string) (ok bool
// groupId是否是ownUserId的? // groupId是否是ownUserId的?
/* /*
if !this.IsExistsGroupUser(ownUserId, groupId) { if !this.IsExistsGroupUser(ownUserId, groupId) {
return false, "forbidden" return false, "forbiddenNotMyGroup"
} }
*/ */
if !this.isMyGroup(ownUserId, groupId) { if !this.isMyGroup(ownUserId, groupId) {
return false, "forbidden" return false, "forbiddenNotMyGroup"
} }
// 删除该用户分享到本组的笔记本, 笔记 // 删除该用户分享到本组的笔记本, 笔记

View File

@ -34,6 +34,7 @@ func (this *PwdService) FindPwd(email string) (ok bool, msg string) {
return return
} }
// 重置密码时
// 修改密码 // 修改密码
// 先验证 // 先验证
func (this *PwdService) UpdatePwd(token, pwd string) (bool, string) { func (this *PwdService) UpdatePwd(token, pwd string) (bool, string) {
@ -45,11 +46,12 @@ func (this *PwdService) UpdatePwd(token, pwd string) (bool, string) {
if ok, msg, tokenInfo = tokenService.VerifyToken(token, info.TokenPwd); !ok { if ok, msg, tokenInfo = tokenService.VerifyToken(token, info.TokenPwd); !ok {
return ok, msg return ok, msg
} }
digest, err := GenerateHash(pwd)
if err != nil { passwd := GenPwd(pwd)
if passwd == "" {
return false, "GenerateHash error" return false, "GenerateHash error"
} }
passwd := string(digest)
// 修改密码之 // 修改密码之
ok = db.UpdateByQField(db.Users, bson.M{"_id": tokenInfo.UserId}, "Pwd", passwd) ok = db.UpdateByQField(db.Users, bson.M{"_id": tokenInfo.UserId}, "Pwd", passwd)