mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-30 19:08:37 +00:00 
			
		
		
		
	#2152 fix SMTP authentication makes invalid assumption on protocol
This commit is contained in:
		| @@ -10,6 +10,7 @@ import ( | |||||||
| 	"errors" | 	"errors" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"net/smtp" | 	"net/smtp" | ||||||
|  | 	"net/textproto" | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| @@ -371,7 +372,11 @@ func LoginUserSMTPSource(u *User, name, passwd string, sourceID int64, cfg *SMTP | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if err := SMTPAuth(auth, cfg); err != nil { | 	if err := SMTPAuth(auth, cfg); err != nil { | ||||||
| 		if strings.Contains(err.Error(), "Username and Password not accepted") { | 		// Check standard error format first, | ||||||
|  | 		// then fallback to worse case. | ||||||
|  | 		tperr, ok := err.(*textproto.Error) | ||||||
|  | 		if (ok && tperr.Code == 535) || | ||||||
|  | 			strings.Contains(err.Error(), "Username and Password not accepted") { | ||||||
| 			return nil, ErrUserNotExist{0, name} | 			return nil, ErrUserNotExist{0, name} | ||||||
| 		} | 		} | ||||||
| 		return nil, err | 		return nil, err | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user