Skip to content
Merged
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
19 changes: 19 additions & 0 deletions service/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@
const { notifyMemberJoined } = require("./lib/notify-member-joined");
const { Mfs } = require("@drumee/server-core");

// Password policy — KEEP IN STEP with PW_RULES in the signup UI
// (signup/src/widgets/form/index.js). The UI checks first for the inline
// message; this is the authoritative check, since the endpoint can be called
// directly. Keys double as the UI's LOCALE keys for the "still needs" list.
const PW_SPECIALS = /[\[\]\{\}\'\"\ \-\_\+\=\|\!\:\;\,\?\.\/\*\%\$\&\#\(\)\@]/;

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \".

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784YqO&open=AaDlxcW106PTyk784YqO&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \%.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784Yqc&open=AaDlxcW106PTyk784Yqc&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \}.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784YqM&open=AaDlxcW106PTyk784YqM&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \!.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784YqU&open=AaDlxcW106PTyk784YqU&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \(.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784Yqg&open=AaDlxcW106PTyk784Yqg&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \'.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784YqN&open=AaDlxcW106PTyk784YqN&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \*.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784Yqb&open=AaDlxcW106PTyk784Yqb&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \ .

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784YqP&open=AaDlxcW106PTyk784YqP&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \_.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784YqQ&open=AaDlxcW106PTyk784YqQ&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \+.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784YqR&open=AaDlxcW106PTyk784YqR&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \|.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784YqT&open=AaDlxcW106PTyk784YqT&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \?.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784YqY&open=AaDlxcW106PTyk784YqY&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \[.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784YqK&open=AaDlxcW106PTyk784YqK&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \;.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784YqW&open=AaDlxcW106PTyk784YqW&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \#.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784Yqf&open=AaDlxcW106PTyk784Yqf&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \{.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784YqL&open=AaDlxcW106PTyk784YqL&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \&.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784Yqe&open=AaDlxcW106PTyk784Yqe&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \,.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784YqX&open=AaDlxcW106PTyk784YqX&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \/.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784Yqa&open=AaDlxcW106PTyk784Yqa&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \@.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784Yqi&open=AaDlxcW106PTyk784Yqi&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \=.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784YqS&open=AaDlxcW106PTyk784YqS&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \).

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784Yqh&open=AaDlxcW106PTyk784Yqh&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \:.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784YqV&open=AaDlxcW106PTyk784YqV&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \$.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784Yqd&open=AaDlxcW106PTyk784Yqd&pullRequest=241

Check warning on line 30 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unnecessary escape character: \..

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784YqZ&open=AaDlxcW106PTyk784YqZ&pullRequest=241
const PW_RULES = [
{ key: "PW_NEEDS_MIN", test: (v) => v.length >= 8 },
{ key: "PW_NEEDS_UPPERCASE", test: (v) => /[A-Z]/.test(v) },
{ key: "PW_NEEDS_NUMBER", test: (v) => /[0-9]/.test(v) },

Check warning on line 34 in service/signup.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use concise character class syntax '\d' instead of '[0-9]'.

See more on https://sonarcloud.io/project/issues?id=drumee_server-team&issues=AaDlxcW106PTyk784Yqj&open=AaDlxcW106PTyk784Yqj&pullRequest=241
{ key: "PW_NEEDS_SYMBOL", test: (v) => PW_SPECIALS.test(v) },
];

class __signup extends Mfs {

/**
Expand All @@ -34,6 +46,13 @@
const email = this.input.need(Attr.email).trim();
const password = this.input.need(Attr.password).trim();

// Checked on the TRIMMED value — the one that is hashed and that login
// (yp.login, session.signin) compares against.
const missing = PW_RULES.filter((r) => !r.test(password)).map((r) => r.key);
if (missing.length) {
return this.output.data({ status: "weak_password", missing });
}

const existingUser = await this.yp.await_proc("drumate_exists", email);
if (existingUser && existingUser.email) {
return this.output.data({ status: "user_exists", email });
Expand Down
Loading