mirror of
https://git.sr.ht/~sircmpwn/tokidoki
synced 2025-12-12 06:07:22 +01:00
Migrate to go-imap v2
v1 is no longer actively maintained. Co-authored-by: Conrad Hoffmann <ch@bitfehler.net>
This commit is contained in:
parent
ebb5aede92
commit
a95896216f
3 changed files with 40 additions and 17 deletions
12
auth/imap.go
12
auth/imap.go
|
|
@ -5,8 +5,7 @@ import (
|
|||
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/emersion/go-imap/client"
|
||||
"github.com/emersion/go-sasl"
|
||||
"github.com/emersion/go-imap/v2/imapclient"
|
||||
)
|
||||
|
||||
type IMAPProvider struct {
|
||||
|
|
@ -50,8 +49,7 @@ func (prov *IMAPProvider) doAuth(next http.Handler,
|
|||
}
|
||||
defer conn.Close()
|
||||
|
||||
auth := sasl.NewPlainClient("", user, pass)
|
||||
if err := conn.Authenticate(auth); err != nil {
|
||||
if err := conn.Login(user, pass).Wait(); err != nil {
|
||||
log.Debug().Str("user", user).Err(err).Msg("auth error")
|
||||
http.Error(w, "Invalid username or password", http.StatusUnauthorized)
|
||||
return
|
||||
|
|
@ -67,10 +65,10 @@ func (prov *IMAPProvider) doAuth(next http.Handler,
|
|||
next.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
func (prov *IMAPProvider) dial() (*client.Client, error) {
|
||||
func (prov *IMAPProvider) dial() (*imapclient.Client, error) {
|
||||
if prov.tls {
|
||||
return client.DialTLS(prov.addr, nil)
|
||||
return imapclient.DialTLS(prov.addr, nil)
|
||||
} else {
|
||||
return client.Dial(prov.addr)
|
||||
return imapclient.DialInsecure(prov.addr, nil)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue