Hello,
Regarding the afterLogin, For the request.object, which is the user, could I attach some extra info and return back to the frontend?
I tested, seems the added extra info will be discarded when frontend got the response … How should I do? Thanks a lot.
Parse.Cloud.afterLogin((request) => {
// code here
});
Cloud - Documentation
Could you share the code that you used to add extra info?
Hi @davimacedo,
The code is as below. While I write my own Login method, which use the phone and password to login, will this be a problem? By my own method, the afterLogin could be triggered as well when login is successful. I just would like to attach the ACL info directly to the user when returned back to frontend.
Parse.Cloud.afterLogin(
async (afterLoginRequest) => {
console.log('afterLoginRequest', afterLoginRequest);
const user = afterLoginRequest.object;
const role = await new Parse.Query(Parse.Role)
.equalTo('name', user.get('roleName'))
.first({ useMasterKey: true });
console.log('user role', role.toJSON());
user.set('roleACL', role.toJSON());
// result.roleACL = role.toJSON();
console.log('afterLogin user.toJSON', user.toJSON());
},
);
I’ve just checked the code. You will have to call user.save()
, otherwise your change will not even be saved on database. The data will not come back to the client in the response though.