Skip to content

Commit

Permalink
[DEV-1574] options.noSignupEmail for signup() (#166)
Browse files Browse the repository at this point in the history
* [DEV-1574] options.noSignupEmail for signup()

* minor version bump
  • Loading branch information
isanchez-userfront authored Oct 10, 2024
1 parent 9c22045 commit 5c7eab8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@userfront/core",
"version": "1.0.1",
"version": "1.1.0",
"description": "Userfront core JS library",
"source": "src/index.js",
"main": "build/userfront-core.js",
Expand Down
3 changes: 3 additions & 0 deletions src/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ import { setupPkce } from "./pkce.js";
* @property {Function} handleTokens
* @property {Function} handleRedirect
* @property {Object} options
* @property {Boolean} options.noResetEmail
* By default, Userfront sends a password reset email if a user without a password tries to log in with a password.
* Set options.noResetEmail = true to override this behavior and return an error instead.
*/
export async function login({
method,
Expand Down
6 changes: 6 additions & 0 deletions src/password.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import { getPkceRequestQueryParams } from "./pkce.js";
* @property {Function} handlePkceRequired
* @property {Function} handleTokens
* @property {Function} handleRedirect
* @property {Object} options
* @property {Boolean} options.noSignupEmail
* By default, Userfront sends a welcome and signup email when registering a new user.
* Set options.noSignupEmail = true to override this behavior.
*/
export async function signupWithPassword({
username,
Expand All @@ -34,6 +38,7 @@ export async function signupWithPassword({
handlePkceRequired,
handleTokens,
handleRedirect,
options,
} = {}) {
try {
const { tenantId } = store;
Expand All @@ -45,6 +50,7 @@ export async function signupWithPassword({
email,
password,
data: userData,
...(options?.noSignupEmail && { options: { noSignupEmail: true } }),
},
{
headers: getMfaHeaders(),
Expand Down
6 changes: 6 additions & 0 deletions src/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import { setupPkce } from "./pkce.js";
* @property {Function} handlePkceRequired
* @property {Function} handleTokens
* @property {Function} handleRedirect
* @property {Object} options
* @property {Boolean} options.noSignupEmail
* By default, Userfront sends a welcome and signup email when registering a new user.
* Set options.noSignupEmail = true to override this behavior.
*/
export async function signup({
method,
Expand All @@ -42,6 +46,7 @@ export async function signup({
handlePkceRequired,
handleTokens,
handleRedirect,
options,
} = {}) {
setupPkce();
if (!method) {
Expand Down Expand Up @@ -71,6 +76,7 @@ export async function signup({
handlePkceRequired,
handleTokens,
handleRedirect,
options,
});
case "passwordless":
return sendPasswordlessLink({ email, name, username, userData: data });
Expand Down
9 changes: 8 additions & 1 deletion ts/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ interface InitOptions {
userfrontSource?: string;
supressNodeWarning?: boolean;
}
export declare function init(tenantId: string, options?: InitOptions): Promise<void>;
export declare function init(
tenantId: string,
options?: InitOptions
): Promise<void>;

// addInitCallback()
export declare function addInitCallback(callback: Function): void;
Expand Down Expand Up @@ -163,6 +166,7 @@ export declare function signup({
handlePkceRequired,
handleTokens,
handleRedirect,
options,
}: {
method: string;
email?: string;
Expand All @@ -178,6 +182,9 @@ export declare function signup({
handlePkceRequired?: Function;
handleTokens?: Function;
handleRedirect?: Function;
options?: {
noSignupEmail?: boolean;
};
}): Promise<SignupResponse>;

// login()
Expand Down

0 comments on commit 5c7eab8

Please sign in to comment.