In your login page, can you determine where the error is, on what line is occurring. Does the console.log lines work, do you see the realLink in the console? Add more console.log lines to let you know where you are in the code and help you debug. Remember to remove them once you have completed your debugging.
Eg: console.log(“calling Wix login now.”)
console.log(“calling checkUserExists function now.”)
console.log(“returned from checkUserExists function.”)
etc.