From 405ee14711ab946bd709ec28a526890c40cbc03b Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 3 Oct 2014 13:12:54 -0400 Subject: [PATCH] Fix SMTP auth logic --- gogs.go | 2 +- models/login.go | 8 ++------ models/user.go | 20 ++++++++++---------- templates/.VERSION | 2 +- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/gogs.go b/gogs.go index 9db5c71a1cc5..289ad1912349 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.4.1001 Beta" +const APP_VER = "0.5.4.1003 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/login.go b/models/login.go index da7722f294a0..2c5fc68e9c79 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 dcf5afa4fb3c..ee8f8586d591 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. diff --git a/templates/.VERSION b/templates/.VERSION index bae760995d7e..24a40ce35805 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.4.1001 Beta \ No newline at end of file +0.5.4.1003 Beta \ No newline at end of file