Beispiel #1
0
Meteor.loginWithPasswordAndTOTP = function(selector, password, code, callback) {
	if (typeof selector === 'string') {
		if (selector.indexOf('@') === -1) {
			selector = { username: selector };
		} else {
			selector = { email: selector };
		}
	}

	Accounts.callLoginMethod({
		methodArguments: [{
			totp: {
				login: {
					user: selector,
					password: Accounts._hashPassword(password),
				},
				code,
			},
		}],
		userCallback(error) {
			if (error) {
				reportError(error, callback);
			} else {
				callback && callback();
			}
		},
	});
};
Beispiel #2
0
	Accounts.saml.initiateLogin(options, function(/* error, result*/) {
		Accounts.callLoginMethod({
			methodArguments: [{
				saml: true,
			}],
			userCallback: callback,
		});
	});
Beispiel #3
0
const blockstackLogin = (authResponse, userData = {}) => {
	Accounts.callLoginMethod({
		methodArguments: [{
			blockstack: true,
			authResponse,
			userData,
		}],
		userCallback() {
			FlowRouter.go('home');
		},
	});
};
Meteor.loginWithLoginToken = function(token) {
	Accounts.callLoginMethod({
		methodArguments: [{
			loginToken: token,
		}],
		userCallback(error) {
			if (!error) {
				FlowRouter.go('/');
			}
		},
	});
};
Beispiel #5
0
const loginWithEmailToken = function (email, token, callback) {
  check(email, String);
  check(token, String);

  // Meteor's `Accounts.callLoginMethod` doesn't provide the login result to the `userCallback` you
  // specify on successful login, so we ordinarily wouldn't be able to redirect you back to the path
  // you initiated email login from.
  //
  // However, Meteor *does* provide the login result to the `validateResult` method.  So, we stash
  // the path we want to pass back to the caller here when `validateResult` is called, and then we
  // can pass it on to the callback in `userCallback` instead.
  let resumePath = undefined;

  Accounts.callLoginMethod({
    methodArguments: [
      {
        email: {
          email: email,
          token: token,
        },
      },
    ],

    validateResult: function (result) {
      resumePath = result.resumePath;
    },

    userCallback: function (error) {
      if (error) {
        callback && callback(error);
      } else {
        callback && callback(undefined, resumePath);
      }
    },
  });
};
Accounts.oauth.tryLinkAfterPopupClosed = function(credentialToken, callback) {
  const credentialSecret = OAuth._retrieveCredentialSecret(credentialToken);
  Accounts.callLoginMethod({
    methodArguments: [
      {
        link: {
          credentialToken: credentialToken,
          credentialSecret: credentialSecret
        }
      }
    ],
    userCallback:
      callback &&
      function(err) {
        // Allow server to specify a specify subclass of errors. We should come
        // up with a more generic way to do this!
        if (err && err instanceof Meteor.Error && err.error === Accounts.LoginCancelledError.numericError) {
          callback(new Accounts.LoginCancelledError(err.details));
        } else {
          callback(err);
        }
      }
  });
};
Beispiel #7
0
	action() {
		FlowRouter.go('home');
	},
});

FlowRouter.route('/home', {
	name: 'home',

	action(params, queryParams) {
		KonchatNotification.getDesktopPermission();
		if (queryParams.saml_idp_credentialToken !== undefined) {
			Accounts.callLoginMethod({
				methodArguments: [{
					saml: true,
					credentialToken: queryParams.saml_idp_credentialToken,
				}],
				userCallback() { BlazeLayout.render('main', { center: 'home' }); },
			});
		} else {
			BlazeLayout.render('main', { center: 'home' });
		}
	},
});

FlowRouter.route('/directory', {
	name: 'directory',

	action() {
		BlazeLayout.render('main', { center: 'directory' });
	},