Lock SMS or Email

Hi,

We want to enable a user to receive the code by email or SMS

Has anybody implemented anything like this?

The Passwordless Lock widget does not support toggling between the two methods within the Lock UI. However, you can handle this by showing the correct Lock UI based on how the login was initiated. For example, you could have two buttons on your UI (e.g. Login with email, Login with SMS), and show the relevant Lock UI based on which was clicked:

HTML
<button onclick="loginEmail()">Login with Email</button>
<button onclick="loginSMS()">Login with SMS</button>

JS
function loginEmail(){
	lock.emailcode();
}

function loginSMS(){
    //Open the lock in SMS mode with the ability to handle the authentication in page
	lock.sms(appearanceOpts,function (error, profile, id_token, access_token, state, refresh_token) {
		if (!error) {
			//usually save profile and id_token
			console.log(id_token);
			console.log(JSON.stringify(profile));
		 }
    });
}