MCPcopy
hub / github.com/dgraph-io/dgraph / resolveLogin

Function resolveLogin

graphql/admin/login.go:28–57  ·  view source on GitHub ↗
(ctx context.Context, m schema.Mutation)

Source from the content-addressed store, hash-verified

26}
27
28func resolveLogin(ctx context.Context, m schema.Mutation) (*resolve.Resolved, bool) {
29 glog.Info("Got login request")
30
31 input := getLoginInput(m)
32 resp, err := (&edgraph.Server{}).Login(ctx, &dgoapi.LoginRequest{
33 Userid: input.UserId,
34 Password: input.Password,
35 Namespace: input.Namespace,
36 RefreshToken: input.RefreshToken,
37 })
38 if err != nil {
39 return resolve.EmptyResult(m, err), false
40 }
41
42 jwt := &dgoapi.Jwt{}
43 if err := proto.Unmarshal(resp.GetJson(), jwt); err != nil {
44 return resolve.EmptyResult(m, err), false
45 }
46
47 return resolve.DataResult(
48 m,
49 map[string]interface{}{
50 m.Name(): map[string]interface{}{
51 "response": map[string]interface{}{
52 "accessJWT": jwt.AccessJwt,
53 "refreshJWT": jwt.RefreshJwt}}},
54 nil,
55 ), true
56
57}
58
59func getLoginInput(m schema.Mutation) *loginInput {
60 // We should be able to convert these to string as GraphQL schema validation should ensure this.

Callers

nothing calls this directly

Calls 6

EmptyResultFunction · 0.92
DataResultFunction · 0.92
getLoginInputFunction · 0.85
InfoMethod · 0.80
LoginMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected