Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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: 6 additions & 1 deletion 7 packages/authentication-local/src/strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,14 @@ export class LocalStrategy extends AuthenticationBaseStrategy {
}

async authenticate (data: AuthenticationRequest, params: Params) {
const { passwordField, usernameField, entity } = this.configuration;
const { passwordField, usernameField, entity, errorMessage } = this.configuration;
const username = data[usernameField];
const password = data[passwordField];

if (!password) { // exit early if there is no password
throw new NotAuthenticated(errorMessage);
}

const result = await this.findEntity(username, omit(params, 'provider'));

await this.comparePassword(result, password);
Expand Down
14 changes: 14 additions & 0 deletions 14 packages/authentication-local/test/strategy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,20 @@ describe('@feathersjs/authentication-local/strategy', () => {
}
});

it('fails when password is not provided', async () => {
const authService = app.service('authentication');
try {
await authService.create({
strategy: 'local',
email,
});
assert.fail('Should never get here');
} catch (error) {
assert.strictEqual(error.name, 'NotAuthenticated');
assert.strictEqual(error.message, 'Invalid login');
}
});

it('fails when password field is not available', async () => {
const userEmail = 'someuser@localtest.com';
const authService = app.service('authentication');
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.