Update readme, create outbox, log remote in IMAP/SMTP auth

This commit is contained in:
Neil Alexander
2021-07-09 19:38:05 +01:00
parent 2565129191
commit ea11f4cf6c
7 changed files with 30 additions and 14 deletions

View File

@@ -18,7 +18,7 @@ type Backend struct {
Storage storage.Storage
}
func (b *Backend) Login(_ *imap.ConnInfo, username, password string) (backend.User, error) {
func (b *Backend) Login(conn *imap.ConnInfo, username, password string) (backend.User, error) {
// If our username is email-like, then take just the localpart
if pk, err := utils.ParseAddress(username); err == nil {
if !pk.Equal(b.Config.PublicKey) {
@@ -34,7 +34,7 @@ func (b *Backend) Login(_ *imap.ConnInfo, username, password string) (backend.Us
b.Log.Printf("Failed to authenticate IMAP user %q\n", username)
return nil, backend.ErrInvalidCredentials
}
defer b.Log.Printf("Authenticated IMAP user %q\n", username)
defer b.Log.Printf("Authenticated IMAP user from %s as %q\n", conn.RemoteAddr.String(), username)
user := &User{
backend: b,
username: username,

View File

@@ -273,6 +273,10 @@ func (mbox *Mailbox) UpdateMessagesFlags(uid bool, seqSet *imap.SeqSet, op imap.
}
func (mbox *Mailbox) CopyMessages(uid bool, seqSet *imap.SeqSet, destName string) error {
if destName == "Outbox" {
return fmt.Errorf("can't copy into Outbox as it is a protected folder")
}
ids, err := mbox.getIDsFromSeqSet(uid, seqSet)
if err != nil {
return fmt.Errorf("mbox.getIDsFromSeqSet: %w", err)

View File

@@ -58,17 +58,21 @@ func (u *User) CreateMailbox(name string) error {
}
func (u *User) DeleteMailbox(name string) error {
if name == "INBOX" {
return errors.New("Cannot delete INBOX")
switch name {
case "INBOX", "Outbox":
return errors.New("Cannot delete " + name)
default:
return u.backend.Storage.MailboxDelete(name)
}
return u.backend.Storage.MailboxDelete(name)
}
func (u *User) RenameMailbox(existingName, newName string) error {
if existingName == "INBOX" {
return errors.New("Cannot rename INBOX")
switch existingName {
case "INBOX", "Outbox":
return errors.New("Cannot rename " + existingName)
default:
return u.backend.Storage.MailboxRename(existingName, newName)
}
return u.backend.Storage.MailboxRename(existingName, newName)
}
func (u *User) Logout() error {