meteor services are now async

This commit is contained in:
Gabriel Grubba
2023-02-13 12:25:30 -03:00
parent 1b1904a7ec
commit 9844bf5e36

View File

@@ -50,10 +50,10 @@ exports.handleConnectionError = function (error, label) {
// domain: the domain (ex: packages.meteor.com)
// sessionType: the name of the connection (ex: "package-server")
//
exports.loggedInConnection = function (url, domain, sessionType) {
exports.loggedInConnection = async function (url, domain, sessionType) {
// Make sure that we are logged in with Meteor Accounts so that we can
// do an OAuth flow.
if (auth.maybePrintRegistrationLink({onlyAllowIfRegistered: true})) {
if (await auth.maybePrintRegistrationLink({ onlyAllowIfRegistered: true })) {
// Oops, we're logged in but with a deferred-registration account.
// Message has already been printed.
throw new exports.AlreadyPrintedMessageError;
@@ -65,13 +65,13 @@ exports.loggedInConnection = function (url, domain, sessionType) {
"Please log in with your Meteor developer account.",
"If you don't have one,",
"you can quickly create one at www.meteor.com.");
auth.doUsernamePasswordLogin({ retry: true });
await auth.doUsernamePasswordLogin({ retry: true });
}
var conn = exports.openServiceConnection(url);
var accountsConfiguration = auth.getAccountsConfiguration(conn);
var conn = await exports.openServiceConnection(url);
var accountsConfiguration = await auth.getAccountsConfiguration(conn);
try {
auth.loginWithTokenOrOAuth(
await auth.loginWithTokenOrOAuth(
conn,
accountsConfiguration,
url,
@@ -86,8 +86,8 @@ exports.loggedInConnection = function (url, domain, sessionType) {
"It looks like you have been logged out!",
"Please log in with your Meteor developer account. If you don't have",
"one, you can quickly create one at www.meteor.com.");
auth.doUsernamePasswordLogin({ retry: true });
auth.loginWithTokenOrOAuth(
await auth.doUsernamePasswordLogin({ retry: true });
await auth.loginWithTokenOrOAuth(
conn,
accountsConfiguration,
url,