Skip to content

3. Logout

Nguyen Ngoc Phuong edited this page Feb 21, 2023 · 1 revision

Currently, the logout feature is just providing a way to customize the logout process. It won't invalidate the token.

Usage:

Request endpoint:

POST /logout

Parameters

Request Field Field Type Required Field Desc
Authorization Bearer true access_token for authenticate

Response

Response Field Field Type Required Field Desc
N/A N/A N/A return code 204 - noContent

Example

curl -X 'POST' \
  'http://localhost/api/logout' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer eyJ0eXAiOiJKV1...' \
  -d ''
{}

Customization

Bellow is the list of configurable method of UserService that can be used to custom your logout behavior. All the methods implementation are available at: https://github.com/sun-asterisk/tech-standard-nest-auth/blob/master/src/baseuser.service.ts

Transform the logout response

This method can be override to transform the response of the logout request. It can also be used for implementing the invalidate token logic. This method accept the access_token of the current logout request, so you can implement the token invalidation logic by yourself.

onBeforeLogoutResponse(accessToken: string): Promise<any>;
Clone this wiki locally