-
Notifications
You must be signed in to change notification settings - Fork 2
/
auth.go
32 lines (28 loc) · 976 Bytes
/
auth.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
package auth
import (
"context"
"strconv"
"github.com/dictyBase/aphgrpc"
"github.com/dictyBase/go-genproto/dictybaseapis/auth"
"github.com/dictyBase/go-genproto/dictybaseapis/identity"
"github.com/dictyBase/go-genproto/dictybaseapis/user"
"github.com/dictyBase/graphql-server/internal/graphql/models"
"github.com/sirupsen/logrus"
)
type AuthResolver struct {
Client auth.AuthServiceClient
UserClient user.UserServiceClient
IdentityClient identity.IdentityServiceClient
Logger *logrus.Entry
}
func (r *AuthResolver) Identity(ctx context.Context, obj *auth.Auth) (*models.Identity, error) {
attr := obj.Identity.Data.Attributes
return &models.Identity{
ID: strconv.FormatInt(obj.Identity.Data.Id, 10),
Identifier: attr.Identifier,
Provider: attr.Provider,
UserID: strconv.FormatInt(attr.UserId, 10),
CreatedAt: aphgrpc.ProtoTimeStamp(attr.CreatedAt),
UpdatedAt: aphgrpc.ProtoTimeStamp(attr.UpdatedAt),
}, nil
}