Skip to content

Commit

Permalink
feat: laravel-sanctum
Browse files Browse the repository at this point in the history
  • Loading branch information
pooya parsa committed Apr 18, 2020
1 parent b0bfafb commit bf63513
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions lib/providers/laravel.sanctum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { assignDefaults } = require('./_utils')

module.exports = function laravelSanctum (strategy) {
const { laravelBaseURL } = strategy

if (!laravelBaseURL) {
throw new Error('laravelBaseURL is required!')
}

const endpointDefaults = {
withCredentials: true,
headers: {
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/json',
Accept: 'application/json'
}
}

assignDefaults(strategy, {
_scheme: 'cookie',
_name: 'laravel.sanctum',
endpoints: {
csrf: {
...endpointDefaults,
url: laravelBaseURL + '/sanctum/csrf-cookie'
},
login: {
...endpointDefaults,
url: laravelBaseURL + '/login'
},
logout: {
...endpointDefaults,
url: laravelBaseURL + '/logout'
},
user: {
...endpointDefaults,
url: laravelBaseURL + '/api/user'
}
},
user: {
property: false
}
})
}

0 comments on commit bf63513

Please sign in to comment.