Add some debug output to auth module

This commit is contained in:
Conrad Hoffmann 2022-05-03 16:59:39 +02:00
parent 001917295d
commit c2f35df455

View File

@ -6,6 +6,8 @@ import (
"github.com/emersion/go-imap/client"
"github.com/emersion/go-sasl"
"git.sr.ht/~sircmpwn/tokidoki/debug"
)
type IMAPProvider struct {
@ -43,6 +45,7 @@ func (prov *IMAPProvider) doAuth(next http.Handler,
conn, err := prov.dial()
if err != nil {
debug.Printf("Auth dial error: %v", err)
http.Error(w, "Temporary authentication error, try again later", http.StatusServiceUnavailable)
return
}
@ -50,6 +53,7 @@ func (prov *IMAPProvider) doAuth(next http.Handler,
auth := sasl.NewPlainClient("", user, pass)
if err := conn.Authenticate(auth); err != nil {
debug.Printf("Auth error: %v", err)
http.Error(w, "Invalid username or password", http.StatusUnauthorized)
return
}