Created
February 16, 2023 18:10
-
-
Save shanwixcode/11b02351b377790c12067e29924538c5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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