GetPassAndLogin uses the given credentials and client to perform the login operation.
(dg *dgo.Dgraph, opt *CredOpt)
| 1171 | |
| 1172 | // GetPassAndLogin uses the given credentials and client to perform the login operation. |
| 1173 | func 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 | |
| 1192 | func IsSuperAdmin(groups []string) bool { |
| 1193 | for _, group := range groups { |
no test coverage detected