I did a custom Log in, my problem is that I manually approve my users on my site, I would like a message that indicates that a user is pending approval if he enters his data in the log in and has not yet been approved. I tried with this message but not works I only display one msg something is missing in conditions I guess. I don’t know what functions to use for members with pending status.
This is my code
I hope you can help me, thank you!
import wixUsers from "wix-users";
import wixLocation from "wix-location";
import wixWindow from "wix-window";
$w.onReady(function () {
$w("#forgotPassword").onClick( (event) => {
//wixWindow.lightbox.close();
wixUsers.promptForgotPassword()
.then( ( ) => {
console.log("Password reset submitted");
} )
.catch( (err) => {
let errorMsg = err; // "The user closed the forgot password dialog"
} );
});
$w("#email").onKeyPress((event) => {
let key = event.key;
$w("#errorMessage").hide();
$w("#pending").hide();
});
$w("#password").onKeyPress((event) => {
let key = event.key;
$w("#errorMessage").hide();
$w("#pending").hide();
if (key === "Enter") {
console.log("Press enter key on password field")
if ($w("#email").valid && $w("#password").valid ) {
let email = $w("#email").value;
let password = $w("#password").value;
wixUsers.login(email,password)
.then( (result) => {
console.log("User is logged in");
wixLocation.to("/account/my-account");
})
.catch ( (err) => {
console.log(err);
console.log("Your member request is waiting approval from the site owner");
$w("#pending").show();
});
} else {
console.log("Some inputs are invalid");
$w("#errorMessage").show();
}
}else {
console.log("did not press enter key");
}
});
$w("#login").onClick((event) => {
console.log("Button was cliecked");
$w("#errorMessage").hide();
$w("#pending").hide();
if ($w("#email").valid && $w("#password").valid) {
let email = $w("#email").value;
let password = $w("#password").value;
wixUsers.login(email,password, {
})
.then( (result) => {
console.log("User is logged in");
wixLocation.to("/account/my-account");
})
.catch ( (err) => {
console.log(err);
console.log("Your member request is waiting approval from the site owner");
$w("#pending").show();
});
}else {
$w("#errorMessage").show();
console.log("Missing information");
}
});
});
function login_person () {
let email = $w("#email").value;
let password = $w("#password").value;
wixUsers.login(email,password,{
})
.then( (result) => {
console.log("User is logged in");
wixLocation.to("/account/my-account");
})
.catch ( (err) => {
console.log(err);
console.log("Your member request is waiting approval from the site owner");
$w("#pending").show();
});
}
export function registerbutton_click(event) {
$w("#Loginbox").hide();
$w("#box3").show();
}

