Closed jimcouts closed 5 years ago
Maybe @eworwa will know something about this. I think that he has been working with the guards and middleware in his project.
I will check the config and the controller for why it is not working.
Thanks @mabasic it's been puzzling me since last night.
Hi @jimcouts ,
What I did in my project (whit similar configuration than yours) is to extend the controller of this package and overwrite the constructor like:
<?php
namespace XXXXXXXXX\Member\Http\Controllers;
use Laravelista\Comments\CommentController;
class Comments extends CommentController
{
public function __construct()
{
$this->middleware('member');
if (config('comments.guest_commenting') == true) {
$this->middleware('auth:member')->except('store');
} else {
$this->middleware('auth:member');
}
}
}
Note how I'm passing the guard member to the auth middleware. Now, I'm not a Laravel expert so I'm no sure this is the right way to accomplish this, or even if there is a different way to do it.
Let me know if this was of help to you.
@eworwa
Many thanks, I'll give this a whirl, and glad to see I wasn't the only one that's crazy with this guard system :) I'll report back and let you know how it goes on my end so that the member can create comments as well!
Now, I'm not a Laravel expert so I'm no sure this is the right way to accomplish this, or even if there is a different way to do it.
Me neither, I'm more of 15+ years with procedural py
myself, but I'm having a blast learning the laravel framework! (Which to me is daunting at times but very rewarding on the end.)
@eworwa - Yeah, it's a no go still, I'm at a loss until I get some time to figure this out later this week coming up. I appreciate the input here.
@jimcouts Have you managed to solve this issue?
@jimcouts Have you managed to solve this issue?
No, we put this on hold while we're building out another part of the system. Were you able to replicate this? If not, I'll setup a remote via AnyDesk to see what we're talking about.
@jimcouts I think that this could be fixed in the latest version. Maybe give it a try. It was missing the web
middleware. Maybe that was the issue.
It's still showing this, since I just redid the config file with:
/**
* The Comment Controller.
* Change this to your own implementation of the CommentController.
* You can use the \Laravelista\Comments\CommentControllerInterface.
*/
'\Laravelista\Comments\CommentController',
/*'controller' => '\XXXXX\Member\Http\Controllers\Comments',*/
Which still shows the following:
Authentication Required to Post a Comment! You must be logged in to post a comment!
Or register to become a member today!
I think if you would like, I can send you an invite to my desktop on a day that works out for us both so you can see what I'm doing here. Also, I will be a patron here soon enough, really love the start of this project and how easy it is to implement into ours, but I know it'll work for others without a problem. :)
I'm off the rest of this weekend, shoot me a way to contact you? If it's in the code with your email in a note somewhere in there I'll shoot you an email.
In your config file you should set your custom controller like this:
/**
* The Comment Controller.
* Change this to your own implementation of the CommentController.
* You can use the \Laravelista\Comments\CommentControllerInterface.
*/
'controller' => '\XXXXX\Member\Http\Controllers\Comments',
Also be sure to follow the code from eworwa in this comment
Important! Don't forget to include the web
middleware. Without it it won't work. See the latest version of the Laravelista\Comments\CommentController
. Don't forget to update to the latest version of the package.
P.S. Thank you for considering to sponsor me on Patreon.
We're using the Laravel Guards system. Has anyone gotten this to work with this yet? We can't seem to get this one to work with this type of setup for commenters:
I've tried to use the following as well:
'controller' => '\XXXXXXXX\Member\Http\Controllers\Comments',
Which is:
It seems it's not seeing my change to the config pointing at the new controller after a dump-autoload as well. So, my question, does this package support the guard system and us defining
'provider' => 'member',
?Because I'm not seeing it pick up the logged in member's session at all, where the member can view their dashboard and etc, but on this blog post, we're trying to get this to work there, and it still shows the login button and it's not seeing they're logged in...