diff options
author | HombreLaser <sebastian-440@live.com> | 2023-05-12 23:01:55 -0600 |
---|---|---|
committer | HombreLaser <sebastian-440@live.com> | 2023-05-12 23:01:55 -0600 |
commit | cbebedd51e1b4a2f709341b792dd073bac83f15d (patch) | |
tree | 832f7e56e430e5863f4381c78c49119339076436 /src/lib/token.ts | |
parent | 385606ee05a8ceb9073169639eb1a311f81cac10 (diff) |
Añadido formulario de edición de cuenta
Diffstat (limited to 'src/lib/token.ts')
-rw-r--r-- | src/lib/token.ts | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/lib/token.ts b/src/lib/token.ts index 05de87e..93ec0cf 100644 --- a/src/lib/token.ts +++ b/src/lib/token.ts @@ -1,4 +1,4 @@ -import { ApiClient } from "../clients/api_client"; +import jwt_decode from "jwt-decode"; import axios from "axios"; export default class Token { @@ -42,4 +42,29 @@ export default class Token { this.logout(); } } + + getEmail() { + return this.decode()?.data; + } + + getRole() { + return this.decode()?.aud; + } + + getJTI() { + return this.decode()?.jti; + } + + getExpirationDate() { + return this.decode()?.exp; + } + + private decode(): { data: string; aud: string; jti: string; exp: number; } | null { + const token = this.get(); + + if(token != null) + return jwt_decode(token); + + return null; + } }
\ No newline at end of file |