Hi,
Having issue with login. I have created 2 entry fields “email” and “password” and 2 buttons “login” and “logout”.
I am the owner. As the owner email + password does not seem to work to log as admin, I sent an invitation with admin rights to another email address of mine. Clicking on “Accept” on the Wix accept page doesn’t remove the “waiting…” or “pending…” (translated from french) statement on my email line in “role and permissions” screen. And the following code returns “status=0” and “responseText=‘’” as error message. Moreover, entering any id or pwd shows (in wixUser.currentUser) I am anyway connected as “member” !
export function login_click(event) {
let email = $w("#input6").value;
let password = $w("#input7").value;
wixUsers.login(email, password)
.then( () => {
console.log("User is logged in");
$w('#table1').show();
} )
.catch( (err) => {
console.log(err);
console.log(email+' '+password);
console.log(wixUsers.currentUser);
} );
}
Question 1 : is it possible to log in as owner ? does it have at least the same rights as admin ?
Question 2 : why does my login fail
Question 3 : why does the application as new admin remain pending (so I guess not recognized) ?
What are you trying to do with the above? Is it your own custom login setup as it needs to be like as shown in the Wix Users API reference for the login function.
https://www.wix.com/corvid/reference/wix-users.html#login
Otherwise, if you are trying to do it with a button on your page, then have a look at this tutorial from Wix which does similar as well.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area
As for logout, then have a read of Steve’s excellent post about it here.
https://www.wix.com/corvid/forum/community-discussion/this-is-how-to-logout-and-go-to-the-page-of-your-choice
This is my login lightbox code.
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( ( ) => {
//
} )
.catch( (err) => {
let errorMsg = err; //"The user closed the forgot password dialog"
});
});
});
export function loginButton_click(event) {
let email = $w("#email").value;
let password = $w("#password").value;
wixUsers.login(email, password)
.then( () => {
console.log("User is logged in");
wixLocation.to("/account/my-account"); //Change the URL ending to whatever page you want to send the user to after they log in.
} )
.catch( (err) => {
console.log(err);
$w("#errorMessage").expand(); // You can delete this line if you are not going to add an error message. Use a regular text element set to 'collapse on load' from the Properties Panel.
} );
}
yeah, my code was copied from your first link. The main issue is probably that for any reason, the application for a new membership is “pending”. And using the owner id/password combination gives the error message “status=0” and “responseText=‘’” .
The purpose is only to allow for data update/insertion in a collection, which seems to need a wixUsers membership to work…
As the page used is password-protected, I guess that giving the password to enter it logs me as “member” without needing an email+password. Should be sufficient… but even with this membership, collection gets not inserted / updated, but it’s not the subject here.
I read somewhere that the owner cannot test live and should transfer the ownership to someone else ? Quite awkward…
https://support.wix.com/en/article/corvid-working-with-contributors#transfer-ownership-and-contribute-as-admin