-
Notifications
You must be signed in to change notification settings - Fork 13
/
otp.go
34 lines (26 loc) · 849 Bytes
/
otp.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package registry
import (
"errors"
"github.com/coretrix/hitrix/service"
"github.com/coretrix/hitrix/service/component/config"
"github.com/coretrix/hitrix/service/component/otp"
"github.com/sarulabs/di"
)
func ServiceProviderOTP() *service.DefinitionGlobal {
return &service.DefinitionGlobal{
Name: service.OTPService,
Build: func(ctn di.Container) (interface{}, error) {
configService := ctn.Get("config").(config.IConfig)
sid, ok := configService.String("sms.twilio.sid")
if !ok {
return nil, errors.New("missing sms.twilio.sid")
}
token, ok := configService.String("sms.twilio.token")
if !ok {
return nil, errors.New("missing sms.twilio.token")
}
verifySID, _ := configService.String("sms.twilio.verify_sid")
return otp.NewOTP(otp.NewTwilioSMSOTPProvider(sid, token, verifySID)), nil
},
}
}