Skip to content

Commit

Permalink
fix: make sure emails can still be sent with SMS enabled (#3795)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas committed Mar 4, 2024
1 parent dee5844 commit 7c68c5a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions driver/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ func (p *Config) SelfServiceFlowLogoutRedirectURL(ctx context.Context) *url.URL
}

func (p *Config) CourierEmailStrategy(ctx context.Context) string {
return p.GetProvider(ctx).String(ViperKeyCourierDeliveryStrategy)
return p.GetProvider(ctx).StringF(ViperKeyCourierDeliveryStrategy, "smtp")
}

func (p *Config) CourierEmailRequestConfig(ctx context.Context) json.RawMessage {
Expand Down Expand Up @@ -1169,7 +1169,6 @@ func (p *Config) CourierChannels(ctx context.Context) (ccs []*CourierChannel, _
}
}
}
return ccs, nil
}

// load legacy configs
Expand All @@ -1188,7 +1187,8 @@ func (p *Config) CourierChannels(ctx context.Context) (ccs []*CourierChannel, _
return nil, errors.WithStack(err)
}
}
return []*CourierChannel{&channel}, nil
ccs = append(ccs, &channel)
return ccs, nil
}

func splitUrlAndFragment(s string) (string, string) {
Expand Down
4 changes: 3 additions & 1 deletion driver/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1157,9 +1157,11 @@ func TestCourierChannels(t *testing.T) {

channelConfig, err := conf.CourierChannels(ctx)
require.NoError(t, err)
require.Len(t, channelConfig, 1)
require.Len(t, channelConfig, 2)
assert.Equal(t, channelConfig[0].ID, "phone")
assert.NotEmpty(t, channelConfig[0].RequestConfig)
assert.Equal(t, channelConfig[1].ID, "email")
assert.NotEmpty(t, channelConfig[1].SMTPConfig)
})

t.Run("case=defaults", func(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions driver/config/stub/.kratos.courier.channels.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
courier:
smtp:
connection_uri: smtp://username:password@smtp.example.com:587
channels:
- id: phone
request_config:
Expand Down

0 comments on commit 7c68c5a

Please sign in to comment.