cookie is an extended version of the local scheme, which instead of using a token, depends on a cookie set by the auth provider.
Options
auth: {
strategies: {
cookie: {
cookie: {
// (optional) If set, we check this cookie existence for loggedIn check
name: 'XSRF-TOKEN', //
},
user: {
property: 'user',
// autoFetch: true
},
endpoints: {
login: { url: '/api/auth/login', method: 'post' },
logout: { url: '/api/auth/logout', method: 'post' },
user: { url: '/api/auth/user', method: 'get' },
// (optional) If set, we send a get request to this endpoint before login
csrf: {
url: ''
}
}
},
}
}
endpoints
Additional Information
Each endpoint is used to make requests using ohmyfetch.
false
.cookie
user
Additional Information
Here you configure the user options. Note that these options should be set in local.user and not in the user endpoints options (local.endpoints.user). Refer to the example above for further clarification.
property
property
can be used to specify which field of the response JSON to be used for value. It can be false
to directly use API response or being more complicated like auth.user
.autoFetch
- Default:
true
endpoints.user: false
for that.TIP: Set this to false when you want to return the user info from your login request to save an extra HTTP roundtrip. To do so, get the response from
loginWith
and pass the data to setUser. Note that, unless you disable the user endpoint withendpoints.user: false
you will still need to implement the user endpoint so that auth can fetch the user information on e.g. page refresh.