Closed gileneusz closed 6 years ago
ok, well you can provide some suggestions or specific areas you got stuck? What did you try that didn't make sense?
sure, I'll try my best to prepare something. I'm almost total beginner and that is my first API by plugin, so it may take some time. I'll post my suggestions here.
I'm stuck on user roles. I don't know what could be the cause.
I'm almost copying-pasting plugin both sites front and back. Logging in properly, no errors within refresh/users network calls. The problem is that when I use on router-link
v-show="$auth.check('admin')"
I got nothing, instead of reciving response from api/auth/user endpoint with data:
{
"status": "success",
"data": {
"id": 1,
"name": "admin",
"email": "admin@admin.com",
"role": "admin",
"created_at": "2018-01-17 22:09:33",
"updated_at": "2018-01-17 22:09:33"
}
}
normal v-show="$auth.check()
works fine, but roles don't. I know I must make sth wrong, but I'm just a beginner, I don't know how to check the cause of the problem.
///solved// on:
Vue.use(require('@websanova/vue-auth'), {
auth: require('@websanova/vue-auth/drivers/auth/bearer.js'),
http: require('@websanova/vue-auth/drivers/http/vue-resource.1.x.js'),
router: require('@websanova/vue-auth/drivers/router/vue-router.2.x.js'),
rolesVar: 'role'
});
I had rolesVar:'type'
instead of rolesVar:'role'
.
There may be added comment, like this:
Vue.use(require('@websanova/vue-auth'), {
auth: require('@websanova/vue-auth/drivers/auth/bearer.js'),
http: require('@websanova/vue-auth/drivers/http/vue-resource.1.x.js'),
router: require('@websanova/vue-auth/drivers/router/vue-router.2.x.js'),
//default column name for role of user from database
rolesVar: 'role'
});
there could be comment on code in demo in login() method. There is no information in demo versions comments that plugin on login method is making calls to
/auth/login
/auth/user
/auth/refresh
and no clear information what data is expected back, or even reference to laravel-api-demo AuthController.php
also Cors.php Middleware needs to be mentioned. I was a bit confused and it took me a long time why plugin is ignoring my token, only to figure it out that headers were not included:
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Headers', 'Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With')
->header('Access-Control-Expose-Headers', 'Authorization')
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
I know that these information seems trivial for advanced users, but for beginners all the things are quite new, even with some experience with postman ;)
@oluudeh This is gold, thank you. Only jwt public key guide need to be added. Maybe in next article? @websanova - worth to consider to link this tutorial in step-by-step guide
@gileneusz thanks. I am working on that.
Once finished with my integration using restify-jwt I'm going to publish a beginners tutorial based on my experience ;) There are a few gotchas on the vue and restify side which I struggled a bit with. :)
I'm trying to understand how to connect vue with laravel passport with multiauth profiles and I'm lost and there is no clear step-by step guide for beginners how to do it. I tried to analize whole v2.x version of app, but there is no clear explanation where to start and code is not commented enough. Sorry to say that, this plugin is great but there is no simple documentation for beginners