Skip to content

Instantly share code, notes, and snippets.

@shanwixcode
Created February 16, 2023 18:10
Show Gist options
  • Select an option

  • Save shanwixcode/11b02351b377790c12067e29924538c5 to your computer and use it in GitHub Desktop.

Select an option

Save shanwixcode/11b02351b377790c12067e29924538c5 to your computer and use it in GitHub Desktop.
import {register} from 'backend/mem-reg.jsw';
import {authentication} from 'wix-members';
import wixLocation from 'wix-location';
$w.onReady(function () {
});
export function register_click(event) {
if($w("#fname").valid && $w("#lname").valid && $w("#email").valid && $w("#pwd").valid) {
$w("#register").disable();
let object = {
email: $w("#email").value,
password: $w("#pwd").value,
options: {
contactInfo: {
firstName: $w("#fname").value,
lastName: $w("#lname").value
}
}
};
register(object).then( (res) => {
//Log user in with res.sessionToken
authentication.applySessionToken(res.sessionToken)
.then( () => {
wixLocation.to('/member-only-page');
});
});
//Handle error with catch statement //Not explained in this tutorial
} else {
//Handle error
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment