diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-10-03 13:12:54 -0400 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-10-03 13:12:54 -0400 |
commit | 405ee14711ab946bd709ec28a526890c40cbc03b (patch) | |
tree | bce1729424a4da952c6b33895d97a42bffb99a41 /models | |
parent | 1126522a99e42039dcf3f3a1f6473797dd84b31f (diff) | |
download | gitea-405ee14711ab946bd709ec28a526890c40cbc03b.tar.gz gitea-405ee14711ab946bd709ec28a526890c40cbc03b.zip |
Fix SMTP auth logic
Diffstat (limited to 'models')
-rw-r--r-- | models/login.go | 8 | ||||
-rw-r--r-- | models/user.go | 20 |
2 files changed, 12 insertions, 16 deletions
diff --git a/models/login.go b/models/login.go index da7722f294..2c5fc68e9c 100644 --- a/models/login.go +++ b/models/login.go @@ -161,12 +161,8 @@ func UserSignIn(uname, passwd string) (*User, error) { return nil, err } - if u.LoginType == NOTYPE { - if has { - u.LoginType = PLAIN - } else { - return nil, ErrUserNotExist - } + if u.LoginType == NOTYPE && has { + u.LoginType = PLAIN } // For plain login, user must exist to reach this line. diff --git a/models/user.go b/models/user.go index dcf5afa4fb..ee8f8586d5 100644 --- a/models/user.go +++ b/models/user.go @@ -600,27 +600,27 @@ type Follow struct { // FollowUser marks someone be another's follower. func FollowUser(userId int64, followId int64) (err error) { - session := x.NewSession() - defer session.Close() - session.Begin() + sess := x.NewSession() + defer sess.Close() + sess.Begin() - if _, err = session.Insert(&Follow{UserId: userId, FollowId: followId}); err != nil { - session.Rollback() + if _, err = sess.Insert(&Follow{UserId: userId, FollowId: followId}); err != nil { + sess.Rollback() return err } rawSql := "UPDATE `user` SET num_followers = num_followers + 1 WHERE id = ?" - if _, err = session.Exec(rawSql, followId); err != nil { - session.Rollback() + if _, err = sess.Exec(rawSql, followId); err != nil { + sess.Rollback() return err } rawSql = "UPDATE `user` SET num_followings = num_followings + 1 WHERE id = ?" - if _, err = session.Exec(rawSql, userId); err != nil { - session.Rollback() + if _, err = sess.Exec(rawSql, userId); err != nil { + sess.Rollback() return err } - return session.Commit() + return sess.Commit() } // UnFollowUser unmarks someone be another's follower. |