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

Function GetPassAndLogin

x/x.go:1173–1190  ·  view source on GitHub ↗

GetPassAndLogin uses the given credentials and client to perform the login operation.

(dg *dgo.Dgraph, opt *CredOpt)

Source from the content-addressed store, hash-verified

1171
1172// GetPassAndLogin uses the given credentials and client to perform the login operation.
1173func GetPassAndLogin(dg *dgo.Dgraph, opt *CredOpt) error {
1174 password := opt.Password
1175 if len(password) == 0 {
1176 var err error
1177 password, err = AskUserPassword(opt.UserID, "Current", 1)
1178 if err != nil {
1179 return err
1180 }
1181 }
1182 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
1183 defer cancel()
1184 if err := dg.LoginIntoNamespace(ctx, opt.UserID, password, opt.Namespace); err != nil {
1185 return errors.Wrapf(err, "unable to login to the %v account", opt.UserID)
1186 }
1187 fmt.Println("Login successful.")
1188 // update the context so that it has the admin jwt token
1189 return nil
1190}
1191
1192func IsSuperAdmin(groups []string) bool {
1193 for _, group := range groups {

Callers 2

getClientWithAdminCtxFunction · 0.92
GetDgraphClientFunction · 0.85

Calls 2

AskUserPasswordFunction · 0.85
LoginIntoNamespaceMethod · 0.80

Tested by

no test coverage detected