diff --git a/frontend/services/token.service.js b/frontend/services/token.service.js new file mode 100644 index 00000000..1a2f1720 --- /dev/null +++ b/frontend/services/token.service.js @@ -0,0 +1,30 @@ +const TOKEN_KEY = 'access_token' +const REFRESH_TOKEN_KEY = 'refresh_token' + +class TokenService { + getToken() { + return localStorage.getItem(TOKEN_KEY) + } + + saveToken(accessToken) { + localStorage.setItem(TOKEN_KEY, accessToken) + } + + removeToken() { + localStorage.removeItem(TOKEN_KEY) + } + + getRefreshToken() { + return localStorage.getItem(REFRESH_TOKEN_KEY) + } + + saveRefreshToken(refreshToken) { + localStorage.setItem(REFRESH_TOKEN_KEY, refreshToken) + } + + removeRefreshToken() { + localStorage.removeItem(REFRESH_TOKEN_KEY) + } +} + +export default new TokenService()