Can anyone provide a clear example of an API endpoint for logging out that allows for deleting the token stored during login instead of relying on the web browser?
It seems there is no documentation available on how LoopBack generates a default user when creating a new project.
Here is my login endpoint implementation:
@post('/users/sessions', {
responses: {
'200': {
description: 'Token',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
token: {
type: 'string',
},
},
},
},
},
},
},
})
async login(
@requestBody(CredentialsRequestBody) credentials: Credentials,
) {
// Verify user credentials
const user = await this.userService.verifyCredentials(credentials);
// Convert User object to UserProfile object
const userProfile = this.userService.convertToUserProfile(user);
// Generate JSON Web Token based on user profile
const token = await this.jwtService.generateToken(userProfile);
// Define returned properties based on User model
const { firstName, lastName, email, id, roles, entreprise, entrepriseId, address, CIN, phoneNumber } = user;
return {
token,
firstName,
lastName,
email,
id,
roles,
entreprise,
entrepriseId,
address,
CIN,
phoneNumber
};
}
Is there an HTTP method for logging out through the API?