mirror of
https://git.sr.ht/~sircmpwn/tokidoki
synced 2025-12-12 14:17:21 +01:00
Add some debug output to auth module
This commit is contained in:
parent
001917295d
commit
c2f35df455
1 changed files with 4 additions and 0 deletions
|
|
@ -6,6 +6,8 @@ import (
|
||||||
|
|
||||||
"github.com/emersion/go-imap/client"
|
"github.com/emersion/go-imap/client"
|
||||||
"github.com/emersion/go-sasl"
|
"github.com/emersion/go-sasl"
|
||||||
|
|
||||||
|
"git.sr.ht/~sircmpwn/tokidoki/debug"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IMAPProvider struct {
|
type IMAPProvider struct {
|
||||||
|
|
@ -43,6 +45,7 @@ func (prov *IMAPProvider) doAuth(next http.Handler,
|
||||||
|
|
||||||
conn, err := prov.dial()
|
conn, err := prov.dial()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
debug.Printf("Auth dial error: %v", err)
|
||||||
http.Error(w, "Temporary authentication error, try again later", http.StatusServiceUnavailable)
|
http.Error(w, "Temporary authentication error, try again later", http.StatusServiceUnavailable)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -50,6 +53,7 @@ func (prov *IMAPProvider) doAuth(next http.Handler,
|
||||||
|
|
||||||
auth := sasl.NewPlainClient("", user, pass)
|
auth := sasl.NewPlainClient("", user, pass)
|
||||||
if err := conn.Authenticate(auth); err != nil {
|
if err := conn.Authenticate(auth); err != nil {
|
||||||
|
debug.Printf("Auth error: %v", err)
|
||||||
http.Error(w, "Invalid username or password", http.StatusUnauthorized)
|
http.Error(w, "Invalid username or password", http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue