Skip to content
This repository was archived by the owner on Nov 21, 2022. It is now read-only.

Commit 01edfdc

Browse files
ArmandoHerrabdeo
authored andcommitted
feat(cognito): fetch current jwt
* Added `fetchJwtToken` to the cognito actions. Updated docs and README. (#10)
1 parent e451187 commit 01edfdc

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

packages/cognito-module/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Vuex module to interface with AWS Cognito
44

5-
Docs Link: Coming Soon!
5+
Docs Link: [https://cognito.vuetifyjs.com/](https://cognito.vuetifyjs.com/)
66

77
Install:
88
```bash

packages/cognito-module/docs/api/actions.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ Fetches the latest information on the current user and session state.
77
this.$store.dispatch('cognito/fetchSession')
88
```
99

10+
### `fetchJwtToken()`
11+
12+
Fetches the current jwtToken associated with the current user and session when available.
13+
14+
```js
15+
this.$store.dispatch('cognito/fetchJwtToken')
16+
```
17+
1018
### `signInUser({ username: String, password: String })`
1119
Signs in an already created user and sets user obj in localstorage with `USER` key
1220

packages/cognito-module/src/actions.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ export default {
1313
}).catch(reject)
1414
}).catch(reject)
1515
}),
16+
fetchJwtToken: ({ commit }) =>
17+
new Promise((resolve, reject) => {
18+
Auth.currentSession().then(session => {
19+
resolve(session.getAccessToken().getJwtToken())
20+
}).catch(reject)
21+
}),
1622
signInUser: ({ commit }, credentials) =>
1723
new Promise((resolve, reject) => {
1824
Auth.signIn(credentials.username, credentials.password).then((user) => {

0 commit comments

Comments
 (0)