-
Notifications
You must be signed in to change notification settings - Fork 13
/
social.go
56 lines (48 loc) · 1.54 KB
/
social.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package registry
import (
"github.com/sarulabs/di"
"github.com/coretrix/hitrix/service"
"github.com/coretrix/hitrix/service/component/config"
"github.com/coretrix/hitrix/service/component/social"
)
func ServiceProviderGoogleSocial() *service.DefinitionGlobal {
return &service.DefinitionGlobal{
Name: service.GoogleService,
Build: func(ctn di.Container) (interface{}, error) {
return &social.Google{}, nil
},
}
}
func ServiceProviderFacebookSocial() *service.DefinitionGlobal {
return &service.DefinitionGlobal{
Name: service.FacebookService,
Build: func(ctn di.Container) (interface{}, error) {
return &social.Facebook{}, nil
},
}
}
func ServiceProviderAppleSocial() *service.DefinitionGlobal {
return &service.DefinitionGlobal{
Name: service.AppleService,
Build: func(ctn di.Container) (interface{}, error) {
configService := ctn.Get(service.ConfigService).(config.IConfig)
var clientID, androidClientID string
teamID := configService.MustString("authentication.apple.team_id")
if clientIDInner, ok := configService.String("authentication.apple.client_id"); ok {
clientID = clientIDInner
}
if androidClientIDInner, ok := configService.String("authentication.apple.android_client_id"); ok {
androidClientID = androidClientIDInner
}
keyID := configService.MustString("authentication.apple.key_id")
privateKey := configService.MustString("authentication.apple.private_key")
return social.NewAppleSocial(
teamID,
clientID,
androidClientID,
keyID,
privateKey,
), nil
},
}
}