mirror of
https://github.com/foxcpp/maddy.git
synced 2025-04-04 21:47:40 +03:00
Now imapsql module does not handle authentication. (it was not doing it so well anyway) sql_table module was introduced and used in the default configuration as a replacement for functionality that was implemented by imapsql before. Parts of maddyctl code were rewritten to make it work transparently with any IMAP backend or credentials store. Closes #212.
39 lines
851 B
Go
39 lines
851 B
Go
package imapsql
|
|
|
|
import (
|
|
"github.com/emersion/go-imap/backend"
|
|
)
|
|
|
|
// These methods wrap corresponding go-imap-sql methods, but also apply
|
|
// maddy-specific credentials rules.
|
|
|
|
func (store *Storage) ListIMAPAccts() ([]string, error) {
|
|
return store.Back.ListUsers()
|
|
}
|
|
|
|
func (store *Storage) CreateIMAPAcct(username string) error {
|
|
accountName, err := prepareUsername(username)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return store.Back.CreateUser(accountName)
|
|
}
|
|
|
|
func (store *Storage) DeleteIMAPAcct(username string) error {
|
|
accountName, err := prepareUsername(username)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return store.Back.DeleteUser(accountName)
|
|
}
|
|
|
|
func (store *Storage) GetIMAPAcct(username string) (backend.User, error) {
|
|
accountName, err := prepareUsername(username)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return store.Back.GetUser(accountName)
|
|
}
|