HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Require a user to login when they view a page created in a custom plugin
Hi
How do I require a user to login when they view a page?
I am looking for something simillar to $sender->permission(array(some.permission))
Is there a method like $sender->somethingLikeRequireALogin() ?
Thanks
0
Comments
I know I can use the code below but there might be a built-in functionality in the framework that I am not aware
$session = Gdn::session();
if($session->IsValid()){
// do something
}
else{
// do something
}
thanks
If you look at the roles in the dashboard, you can see that guests do not have the permission to sign in. Hence
$sender->permission('Garden.SignIn.Allow');
is what you are looking forSomething like this would do the trick if you actually want to redirect.
That's similar to what we do with the private communities feature:
Vanilla forums community is very helpful, Thanks!