help to correctly configure user authorization via http …
the code i came to
import {ok, notFound, serverError} from 'wix-http-functions';
import wixUsersBackend from 'wix-users-backend';
export function use_myFunction(request) {
let options = {
"headers": {"Content-Type": "application/json"}
};
let user = myBackendFunction(request.path[0],request.path[1])
if(user) {
return ok({body: user});
} else{
const body = "Error";
return notFound({body:body});
}
}
export function myBackendFunction(email, password) {
return wixUsersBackend.login(email, password)
.then( (sessionToken) => {
return {sessionToken, "approved": true};
} )
.catch( (error) => {
return {"approved": false, "reason": error};
} );
}