Comments (10)
Thank you very much.
from laravel-database-schedule.
As long as you register your gate after this one, yours will override.
So if you put it in your App Service Provider*, you're good 👍
from laravel-database-schedule.
Thank you. I've just tried this, returning false in the gate definition, and I can still access the webpage (/schedule).
This is the contents of app/Providers/AppServiceProvider.php
:
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Gate::define('viewDatabaseSchedule', function ($user) {
return false;//$user->hasRole('Administrator');
});
}
}
And now I think about it, the default gate provided by the package should have denied access before I added my overriding gate above, but it let me access the webpage. The default gate is:
Gate::define('viewDatabaseSchedule', function ($user) {
return in_array($user->email, [
//
]);
});
So either I'm doing something wrong (likely) or the access control doesn't work.
from laravel-database-schedule.
I have improved the documentation a little, but after that I saw that the @cja-github question has not yet been answered, I am doing some more tests and I will update again, give me a few minutes to do so.
from laravel-database-schedule.
I added a configuration to make the route public and left the gate by default false, so it is mandatory to inform a gate if the route is not public.
I also updated the documentation to explain this situation.
If you have any suggestions for improving the documentation or implementing the access restriction, please send a pull request, I will be happy to review and approve.
Thank you for your contribution @cja-github @JohnRoux
I will close this issue, but if they still find any problem they can reopen.
from laravel-database-schedule.
I need to know how to do this. I cannot use this package if its webpage will be public.
from laravel-database-schedule.
Hi, I've been very busy for the past few weeks, I will try to improve the documentation now.
But basically the package requires that you have a Gate called "viewDatabaseSchedule" defined in some Service Provider, in it you can do the validation that you find most convenient to your business rule.
I don't recommend leaving the cron configuration in public mode, but if you wish you can simply return true to your gate.
Example:
Gate::define('viewDatabaseSchedule', function ($user) {
return true;
});
I will add a little more documentation.
Thank you for your interest.
from laravel-database-schedule.
Thank you for your reply.
I see you provide a gate in called viewDatabaseSchedule
in vendor/robersonfaria/laravel-database-schedule/src/DatabaseScheduleApplicationServiceProvider.php
.
If I add another gate with the same name then will the gate I add override your gate? Or will they conflict with each other in some way?
from laravel-database-schedule.
from laravel-database-schedule.
Do you mean that if I change APP_ENV
in .env
to production
then the gate should work?
I just did that then ran php artisan cache:clear
and was still able to load the webpage.
Hopefully I did the wrong thing...
from laravel-database-schedule.
Related Issues (20)
- `schedule:list` shows no configured schedules HOT 7
- Duplicate output when send mail HOT 4
- In case of failure, duplicate emails are sent HOT 2
- Is possible to add stop run current job when get false from before url? HOT 4
- Update documentation HOT 3
- Creation of new tests (PHPUnit)
- Create new command without options set the options to empty string HOT 2
- Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior HOT 2
- Setting verbosity not possible? HOT 4
- Can't update Name of a scheduled task
- not able to change Timezone HOT 4
- Add ability to schedule server commands instead of artisan HOT 2
- can't override viewDatabaseSchedule gate in custom or app service provider HOT 2
- service without Run the artisan command "php artisan schedule:run"
- Add a button to run the scheduled job "now" HOT 1
- php artisan schedule:list command not list schedules saves at bd
- Laravel 11 Support HOT 3
- Laravel 11 support HOT 1
- Target class [App\Console\Kernel] does not exist.
- Unable to install package on laravel 11 project. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-database-schedule.