authentication.onLogin doesn't return member id

I’m new to Velo and from the docs (https://www.wix.com/velo/reference/wix-members/authentication-obj/onlogin) it seem that the onLogin callback should have an event with the logged in member id. But when I hook it up the event is empty, { } and I can’t get the logged in member id.
Can someone help me figure out why I’m not seeing the event described in the docs.

// masterPage.js
import { authentication } from ‘wix-members’ ;
$w . onReady ( function () {
authentication . onLogin (( event ) => {
console . log ( logged in member id ${ memberId });
});
});

For further info I’m logging in using authentication . applySessionToken ( sessionToken )
using the pattern laid out in the “Log a member in after 3rd-party authentication” example on this page https://www.wix.com/velo/reference/wix-members-backend/authentication-obj/generatesessiontoken

Tested the new onLogin-function and yes you are right, no results given after onLogin.

The whole result-object is —> EMPTY.


The shown example in the Velo-API-DOC seems to be incomplete.

On the one side you have this example here…

import { authentication } from 'wix-members';

// ...

authentication.onLogin((memberInfo) => {
  const memberId = memberInfo.id;
  console.log('Member logged in');
});

/* Full event object:
 * {
 *   "id": "f32cbc51-a331-442b-86c2-2c664613e8b9"
 * }
 */

Which indeed do not work like it should - - > no returned results given (like shon above in the CONSOLE-LOG).

On other side, the description of the API is also confusing.
It is written in the description that…

On the one hand you have…


…on the other hand you have this one…

VERY CONFUSING isn’t it???

And as result you get → NOTHING after LOGIN!

I would suggest you to use the OLD-VERSION, which still works and gives you back at least as result the —> USER-ID.

import wixUsers from 'wix-users';

//On-Login-Process...
    wixUsers.onLogin(async(user) => {console.log("On-Login-running...");           
    console.log(user);                
});

Thanks for investigating, Dima! I will let the product team know about this issue.

@marlowe-shaeffer THANKS miss Marlowe :blossom:
BTW: It would be great not just to get the Member-ID after login-process.
Take a look onto my last comment below.

Than it would’t be neccessary to start an further function to get all the needed Member-Details.

While you do some bug-fixing on wix-side…

A possible SOLUTION could be running this function after Login in the onLogin part, to get all needed DATA…

function get_CurrentMember() {
    let options = {fieldsets: [ 'FULL' ]}
    currentMember.getMember(options)
    .then((member) => {console.log("Member: ", member);
        const memberID = member._id; console.log("Member-ID: ", memberID)
        const fullName = `${member.contactDetails.firstName} ${member.contactDetails.lastName}`; console.log(fullName);
        return member;
    })
    .catch((err) => {console.error(err);});
}

Take also a look onto this post here…

You can do a quick test on the following site…

https://russian-dima.wixsite.com/login-system/vnloginmgm

Login and take a look what you get!

@russian-dima I agree would be nice to just get the member obj

good to know it’s not working. Will use the older interface.

yes, I’ve ended up doing something like that. Thx

Can this be fixed?
Being able to only obtain the member info on a login event and, apparently only on the front-end seems like a non-positive feature.

Any movement on this?

@jim44156 The bug was resolved and onLogin returns the Member ID. Are you asking for additional member info to be returned, and for the function to be available in the back-end?

Yes.

Being able to only obtain the member info on a login event and, apparently only on the front-end seems like a non-positive feature.

Please submit your request to the Velo Wishlist and make sure to include a use case and as many details as possible: https://www.wix.com/velo/wishlist

The more information you provide, the easier it is for our product teams to understand and fulfill the requests. Thanks.

AFIK, this is advertised functionality that is not working as described for the getMember( ) (Introduction - Velo API Reference - Wix.com)

And elaborated at: