feat(auth0-js): correct dbconnection signup details (#41847)

- property name (`userMetadata`)
- missing props
- props documentation
- typed signup callback results options

https://git.io/Jvqte

Thanks!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz) 2020-01-25 02:00:47 +01:00 committed by Ben Lichtman
parent f0232f626b
commit 3061712f65
2 changed files with 49 additions and 7 deletions

View File

@ -150,7 +150,7 @@ webAuth.signupAndAuthorize({
password: '123456',
scope: 'openid',
username: "blabla",
user_metadata: {
userMetadata: {
foo: 'bar'
}
}, (err, data) => {});
@ -263,9 +263,40 @@ authentication.getUserCountry((err, data) => {});
authentication.getSSOData();
authentication.getSSOData(true, (err, data) => {});
// $ExpectError
authentication.dbConnection.signup();
// $ExpectError
authentication.dbConnection.signup({});
// $ExpectError
authentication.dbConnection.signup({ connection: 'bla', email: 'blabla' });
// $ExpectError
authentication.dbConnection.signup({ connection: 'bla', email: 'blabla', password: '123456' });
authentication.dbConnection.signup(
{ connection: 'bla', email: 'blabla', password: '123456', username: 'blabla' },
() => {}
(auth0Error, results) => {
if (auth0Error) {
const { error, errorDescription } = auth0Error;
}
if (results) {
const { email, emailVerified } = results;
}
},
);
authentication.dbConnection.signup(
{
email: 'the email',
password: 'the password',
connection: 'the_connection',
userMetadata: {
firstName: 'Toon',
lastName: 'De Coninck',
last_location: 'Mexico',
},
},
(err, data) => {
console.assert(err === null);
console.assert(data.email !== null);
},
);
authentication.dbConnection.changePassword({connection: 'bla', email: 'blabla'}, () => {});

View File

@ -113,11 +113,10 @@ export class DBConnection {
constructor(request: any, option: any);
/**
* Signup a new user
*
* @param options: https://auth0.com/docs/api/authentication#!#post--dbconnections-signup
* Creates a new user in a Auth0 Database connection
* @param options https://auth0.com/docs/api/authentication#signup
*/
signup(options: DbSignUpOptions, callback: Auth0Callback<any>): void;
signup(options: DbSignUpOptions, callback: Auth0Callback<DbSignUpResults>): void;
/**
* Initializes the change password flow
@ -834,13 +833,25 @@ export interface DelegationOptions {
}
export interface DbSignUpOptions {
/** user email address */
email: string;
/** user password */
password: string;
/** name of the connection where the user will be created */
connection: string;
/** User desired username. Required if you use a database connection and you have enabled `Requires Username` */
username?: string;
scope?: string;
user_metadata?: any;
/** additional signup attributes used for creating the user. Will be stored in `user_metadata` */
userMetadata?: any;
}
/** result of the signup request */
export interface DbSignUpResults {
/** user's email */
email: string;
/** if the user's email was verified */
emailVerified: boolean;
}
export interface ParseHashOptions {