Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix!: api login should not suggest which credential is wrong" #32156

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .changeset/fuzzy-cherries-buy.md

This file was deleted.

14 changes: 14 additions & 0 deletions apps/meteor/app/lib/server/lib/loginErrorMessageOverride.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Do not disclose if user exists when password is invalid
import { Accounts } from 'meteor/accounts-base';
import { Meteor } from 'meteor/meteor';

const { _runLoginHandlers } = Accounts;
Accounts._runLoginHandlers = function (methodInvocation, options) {
const result = _runLoginHandlers.call(Accounts, methodInvocation, options);

if (result.error && result.error.reason === 'Incorrect password') {
result.error = new Meteor.Error(403, 'User not found');
}

return result;
};
16 changes: 0 additions & 16 deletions apps/meteor/app/lib/server/lib/loginErrorMessageOverride.ts

This file was deleted.

10 changes: 10 additions & 0 deletions apps/meteor/client/meteorOverrides/login/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ import { overrideLoginMethod, type LoginCallback } from '../../lib/2fa/overrideL
import { wrapRequestCredentialFn } from '../../lib/wrapRequestCredentialFn';
import { createOAuthTotpLoginMethod } from './oauth';

declare module 'meteor/accounts-base' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Accounts {
export const _options: {
restrictCreationByEmailDomain?: string | (() => string);
forbidClientAccountCreation?: boolean | undefined;
};
}
}

declare module 'meteor/meteor' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Meteor {
Expand Down
10 changes: 1 addition & 9 deletions apps/meteor/definition/externals/meteor/accounts-base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ declare module 'meteor/accounts-base' {

function _insertLoginToken(userId: string, token: { token: string; when: Date }): void;

function _runLoginHandlers<T>(methodInvocation: T, loginRequest: Record<string, any>): Promise<LoginMethodResult>;
function _runLoginHandlers<T>(methodInvocation: T, loginRequest: Record<string, any>): LoginMethodResult | undefined;

function registerLoginHandler(name: string, handler: (options: any) => undefined | object): void;

Expand Down Expand Up @@ -54,14 +54,6 @@ declare module 'meteor/accounts-base' {

const _accountData: Record<string, any>;

interface AccountsServerOptions {
ambiguousErrorMessages?: boolean;
restrictCreationByEmailDomain?: string | (() => string);
forbidClientAccountCreation?: boolean | undefined;
}

export const _options: AccountsServerOptions;

// eslint-disable-next-line @typescript-eslint/no-namespace
namespace oauth {
function credentialRequestCompleteHandler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('[Failed Login Attempts]', function () {
.expect(401)
.expect((res) => {
expect(res.body).to.have.property('status', 'error');
expect(res.body).to.have.property('message', 'Unauthorized');
expect(res.body).to.have.property('message', 'Incorrect password');
});
}

Expand Down
Loading