Skip to content

Commit

Permalink
fix(GODT-2774): Add context parameter to Authorize() on Connector
Browse files Browse the repository at this point in the history
  • Loading branch information
LBeernaertProton committed Jul 6, 2023
1 parent 02a8a9f commit a9327fb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion connector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var ErrMessageSizeExceedsLimits = errors.New("message size exceeds limits")
// Connector connects the gluon server to a remote mail store.
type Connector interface {
// Authorize returns whether the given username/password combination are valid for this connector.
Authorize(username string, password []byte) bool
Authorize(ctx context.Context, username string, password []byte) bool

// CreateMailbox creates a mailbox with the given name.
CreateMailbox(ctx context.Context, name []string) (imap.Mailbox, error)
Expand Down
2 changes: 1 addition & 1 deletion connector/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func NewDummy(usernames []string, password []byte, period time.Duration, flags,
return conn
}

func (conn *Dummy) Authorize(username string, password []byte) bool {
func (conn *Dummy) Authorize(_ context.Context, username string, password []byte) bool {
if bytes.Compare(password, conn.password) != 0 {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion internal/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (b *Backend) getUserID(ctx context.Context, username string, password []byt
b.loginWG.Wait()

for _, user := range b.users {
if user.connector.Authorize(username, password) {
if user.connector.Authorize(ctx, username, password) {
atomic.StoreInt32(&b.loginErrorCount, 0)
return user.userID, nil
}
Expand Down

0 comments on commit a9327fb

Please sign in to comment.