Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
TharindaPrabhath committed Oct 1, 2021
1 parent 8355063 commit 4bf8ccd
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion src/utils/useTokenService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,54 @@ const useTokenService = () => {
const setAccessToken = (accessToken: string) => {
localStorage.setItem("accessToken", accessToken);
}

const setRefreshToken = (refreshToken: string) => {
localStorage.setItem("refreshToken", refreshToken);
}

const setAccessTokenExpiresAt = (expiresAt: string) => {
localStorage.setItem("accessTokenExpiresAt", expiresAt);
}

const setRefreshTokenExpiresAt = (expiresAt: string) => {
localStorage.setItem("refreshTokenExpiresAt", expiresAt);
}

const getAccessToken = () => {
return localStorage.getItem("accessToken");
}

const getRefreshToken = () => {
return localStorage.getItem("refreshToken");
}

const getAccessTokenExpiresAt = () => {
return localStorage.getItem("accessTokenExpiresAt");
}

const getRefreshTokenExpiresAt = () => {
return localStorage.getItem("refreshTokenExpiresAt");
}

const removeAccessToken = () => {
localStorage.removeItem("accessToken");
}

return {setAccessToken, getAccessToken, removeAccessToken}
const removeRefreshToken = () => {
localStorage.removeItem("refreshToken");
}

const removeAccessTokenExpiresAt = () => {
localStorage.removeItem("accessTokenExpiresAt");
}

const removeRefreshTokenExpiresAt = () => {
localStorage.removeItem("refreshTokenExpiresAt");
}

return {setAccessToken, setRefreshToken, setAccessTokenExpiresAt, setRefreshTokenExpiresAt, getAccessToken,
getRefreshToken, getAccessTokenExpiresAt, getRefreshTokenExpiresAt, removeAccessToken, removeRefreshToken,
removeAccessTokenExpiresAt, removeRefreshTokenExpiresAt}
}

export default useTokenService;

0 comments on commit 4bf8ccd

Please sign in to comment.