-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,19 @@ Authenticating users with `authenticate` method: | |
```vue | ||
<script lang="ts" setup> | ||
const client = useMedusaClient(); | ||
await client.auth.authenticate({ email: '[email protected]', password: 'test1234' }); | ||
</script> | ||
``` | ||
|
||
This will create a new cookie called `connect.sid` that will have a `httpOnly` flag set to true (which means that it is not accessible from the frontend JS code). | ||
|
||
You can now fetch the data about currently logged in user like following: | ||
|
||
```vue | ||
<script lang="ts" setup> | ||
const client = useMedusaClient(); | ||
const { customer } = await client.auth.getSession() | ||
</script> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { serverMedusaClient } from '#medusa/server' | ||
|
||
export default eventHandler(async (event) => { | ||
const client = serverMedusaClient(event) | ||
|
||
const { customer } = await client.auth.getSession({ | ||
Cookie: event.node.req.headers.cookie, | ||
}); | ||
|
||
return customer | ||
}) |
a69d1f4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nuxt-medusa – ./
nuxt-medusa-git-main-baroshem.vercel.app
nuxt-medusa-baroshem.vercel.app
nuxt-medusa.vercel.app