Make IMAP and SMTP sessions check for passwords

This commit is contained in:
2018-03-06 00:49:35 +00:00
parent 5aa6607746
commit 32df489b50
5 changed files with 51 additions and 14 deletions

View File

@@ -2,6 +2,7 @@ package imap
import (
"context"
"fmt"
"io"
"log"
"sync/atomic"
@@ -70,14 +71,21 @@ func (c *concrete) Run() {
// backend implementation for go-imap
func (c *concrete) Login(user, pass string) (imapbackend.User, error) {
// FIXME: TODO: Check for account existence and correct password(!)
account, err := c.store.FindAccountWithPassword(user, pass)
if err != nil {
// Lo the real error, but don't show it to the end user
log.Printf("Opening %s session for %s failed: %s", c.name, user, err)
return nil, fmt.Errorf("Login failed")
}
session := &Session{
ID: atomic.AddUint64(&c.sid, uint64(1)),
AccountName: user,
Account: account,
ServiceName: c.name,
}
log.Printf("Beginning %s session %d for %s", c.name, session.ID, user)
// FIXME: TODO: Track ongoing sessions for termination or notifications
return session, nil
}