If its just this instance, I would just check so that you can return an appropriate message.
But first, why show them the button or link to create a thread?
In the controller,
public function store()
{
if(!Auth::user()->verified) {
return redirect()->back->withError('I\'m really sorry you typed that long response, but you need to verify your address first');
}
@Snapey i do hide the button , but the form can still be accessed if you just put the path in the url like
example.com/threads/create
Should i let the users access the form, even if they have to manually enter the path in the url ?
Or i should add a middleware to prevent them from accessing the form even by entering the path in the url manually ? And then also have the code that you posted.
Does it make sense to have both middleware and authorisation ? this was my question
public function store()
{
if(!Auth::user()->verified) {
return redirect()->back->withError('I\'m really sorry you typed that long response, but you need to verify your address first');
}
Basically when users have not confirmed their email, i want to restrict access to several routes.
Right now i use policies, users can access the routes, and for each case i have a different authorisation message when they try to "create a thread" for example, but i don't return back with error like the example code you provided above.