Accounts.validateLoginAttempt is not a function

I installed useraccounts:unstyled and accounts-password.

When I try the code

import { Accounts } from 'meteor/accounts-base';
Accounts.validateLoginAttempt(function(options) {
    return true;
});

It gives me the error

Uncaught TypeError: Accounts.validateLoginAttempt is not a function
    at login.js (login.js:41)
    at fileEvaluate (modules-runtime.js?hash=d9c2212c27b8b694a403c725c46ea2897298b66e:353)
    at require (modules-runtime.js?hash=d9c2212c27b8b694a403c725c46ea2897298b66e:248)
    at home.js (home.js:1)
    at fileEvaluate (modules-runtime.js?hash=d9c2212c27b8b694a403c725c46ea2897298b66e:353)
    at require (modules-runtime.js?hash=d9c2212c27b8b694a403c725c46ea2897298b66e:248)
    at routes.js (routes.js:1)
    at fileEvaluate (modules-runtime.js?hash=d9c2212c27b8b694a403c725c46ea2897298b66e:353)
    at require (modules-runtime.js?hash=d9c2212c27b8b694a403c725c46ea2897298b66e:248)
    at index.js (index.js:1)

Why is it not working?

Where are you doing this? Accounts.validateLoginAttempt is only available on the server.

2 Likes

@robfallows thank you! i got same problem, and your reply helped me out.
just put this funtion to an accountServer.js, and import to server main.js then works fine;

still confused which account config account template…should be on client or server; maybe all on the server?

Robin

I’m not sure quite what you’re asking, but the place to get this information is the Meteor Docs. Just check the information at the top of each documented method. For example, for validateLoginAttempt:

thanks! most are fine -show it’s on server or both; i used to put all account settings in a file under /lib folder and import it to both client and server main.js; all others are fine, but this one didn’t - i had to add if Meteor is server or it’s not working;

also, this Account.config , can’t find it anywhere, but does work…

Accounts.config({
restrictCreationByEmailDomain:‘xxx.com’,
});

Accounts and server pagination are necessary packages for every web app. hope there are some examples