Login Page

I tried doing it with drag&drop but its most likely impossible to do it this way.
So i need if anyone has expirience with JS(because i dont :P) to tell me if it is easy code to do, or ideally if he has an example ready…
Basicly all i need it to do is check the database and if email and password matches, find the ClientID of the matched record,and redirect the client to example.com/client-data/ClientID

Maria, why won’t you use the regular site login? I am aware you can’t customize its design, but the log in UI is built by Wix to support industry security standards.

I have created my own UI https://www.wix.com/code/home/forum/questions-answers/ui-database-problems
Can i do this with the regular site login?I mean redirect to the example.com/client-data/ClientID?

Hi Maria,

As a general guideline, it is always best to use a login service such as Wix Members Login to make sure it is secure. For instance, a login service is expected to be using cookies and passwords stored using one way encryption.

One of the things we are considering is how to introduce an API for Members login and registration. Had we such an API, you should have wired your form to such an API.

The form you have created now is set as an edit form for the values in the database. It will load the first item and allow the user to modify the values that are stored in the DB. This is probably not what you want from a login form.

If I understand you right, you want a user to be redirected to a personal page after login. The way I’d approach this is to use the APIs in wix-users to ensure we have a logged in user and get the user id. Using those, create a button “my personal page” that is only enabled for logged in users and performs this redirect.

It will look something like

import wixUsers from 'wix-users';
import wixLocation from 'wix-location';

$w.onReady(() => {
  if (!wixUsers.currentUser.LoggedIn)
    $w('#personalPage').disable();
});

export function personalPage_onClick() {
  let userId = wixUsers.currentUser.id
  wixLocation.to(`/client-data/${userId}`);
}

Thank you so much for your answer,that is exactly what i want to do.
But because im rly new to code, where do i paste the code to?
If i i understood corectly, i just paste this in a JS file, and make a button tagged as #personalPage element?
But how does the $userID that is specified in wix users API will be matched in my database?I mean doesnt wix-users API has different user ID that the one i have on my database?would it work if i went like this?
location.to(/client-data/${email}); email would be the same, so i think it would work

Or, is there a way for me to somehow get the userID at the first placed, when i register the user(it will be a manual registration - not an automatic one - i will create the member profiles via an admin-create profile page)so that i can place it in the database and this way the userID from the API will be the same in the database

Ho, I see in the example I have made a mistake.

Should have been wixLocation, not location (see the next to last line above)

As for the userId in the database - you will need to input the same userId in the database as in the user registration system. Whenever a user at Wix enters a value to the database, the _owner field is set to the same userId. We are working on having a better experience for getting the userId in other cases.

Code works now!Thanks.
Uhmm, i didn’t quite understand how i will take the reg.system’s user id to put it in the database…
I thought of another way…
I will just make the UI page members only, and use the example.com/clientslist/EMAIL
this way,only when a member is logged in will be able to access the page,and by the email, the page will display the right content!!
wixLocation.to(/client-data/${userId});
to redirect to the email i will just have to change it to
wixLocation.to(/client-data/${email}); ?
i tried that but didn’t seem to work…

Any ideas? :frowning: