(connInfo *imap.ConnInfo, username, password string)
| 279 | } |
| 280 | |
| 281 | func (endp *Endpoint) Login(connInfo *imap.ConnInfo, username, password string) (imapbackend.User, error) { |
| 282 | // saslAuth handles AuthMap calling. |
| 283 | err := endp.saslAuth.AuthPlain(username, password) |
| 284 | if err != nil { |
| 285 | endp.log.Error("authentication failed", err, "username", username, "src_ip", connInfo.RemoteAddr) |
| 286 | return nil, imapbackend.ErrInvalidCredentials |
| 287 | } |
| 288 | |
| 289 | storageUsername, err := endp.usernameForStorage(context.TODO(), username) |
| 290 | if err != nil { |
| 291 | if errors.Is(err, imapbackend.ErrInvalidCredentials) { |
| 292 | return nil, err |
| 293 | } |
| 294 | endp.log.Error("authentication failed due to an internal error", err, "username", username, "src_ip", connInfo.RemoteAddr) |
| 295 | return nil, fmt.Errorf("internal server error") |
| 296 | } |
| 297 | |
| 298 | return endp.Store.GetOrCreateIMAPAcct(storageUsername) |
| 299 | } |
| 300 | |
| 301 | func (endp *Endpoint) I18NLevel() int { |
| 302 | be, ok := endp.Store.(i18nlevel.Backend) |
nothing calls this directly
no test coverage detected