-
Notifications
You must be signed in to change notification settings - Fork 9
/
authentication_service.go
56 lines (43 loc) · 1.47 KB
/
authentication_service.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 security
import (
"context"
"github.com/colibri-project-io/colibri-sdk-go/pkg/base/config"
"github.com/colibri-project-io/colibri-sdk-go/pkg/base/logging"
)
const (
connection_error = "An error occurred when trying to connect to the authentication service. Error: %s"
)
type authenticationService interface {
GetUser(ctx context.Context, id string) (*User, error)
CreateUser(ctx context.Context, user *UserCreate) error
UpdateUser(ctx context.Context, id string, user *UserUpdate) error
DeleteUser(ctx context.Context, id string) error
EnableUser(ctx context.Context, id string) error
DisableUser(ctx context.Context, id string) error
}
var instance authenticationService
func InitializeAuthenticationService() {
switch config.CLOUD {
case config.CLOUD_FIREBASE:
instance = newFirebaseAuthenticationService()
}
logging.Info("Authentication service connected")
}
func GetUser(ctx context.Context, id string) (*User, error) {
return instance.GetUser(ctx, id)
}
func CreateUser(ctx context.Context, user *UserCreate) error {
return instance.CreateUser(ctx, user)
}
func UpdateUser(ctx context.Context, id string, user *UserUpdate) error {
return instance.UpdateUser(ctx, id, user)
}
func DeleteUser(ctx context.Context, id string) error {
return instance.DeleteUser(ctx, id)
}
func EnableUser(ctx context.Context, id string) error {
return instance.EnableUser(ctx, id)
}
func DisableUser(ctx context.Context, id string) error {
return instance.DisableUser(ctx, id)
}