Laravel - The [login] attribute is required Sentry2 Auth - laravel

Any idea's why i get the following error
The [login] attribute is required - what does it mean?
when trying to login with Sentry 2 & Laravel.?

If you need to use anything different from login as attribute in your users table, email for example, first publish the Sentry config:
php artisan config:publish cartalyst/sentry
Then open file app\config\packages\cartalyst\sentry\config.php and edit:
'login_attribute' => 'email',

Related

Laravel 8: error when routing a GET to any view and receiving a error "Trying to get property 'user_id' of non-object"

I've created a new Laravel 8 app with Jetstream and Livewire. When I make a GET request to any view an ErrorException is launched with message
Trying to get property 'user_id' of non-object
on navigation-dropdown.blade.php which is automatically generated by Jetstream\Livewire. I've looked for this user_id and didn't found on any part of the code.
Check that if user has team in the blade view.
resources/views/navigation-dropdown.blade.php
In line 61:
- #if (Laravel\Jetstream\Jetstream::hasTeamFeatures())
+ #if (Laravel\Jetstream\Jetstream::hasTeamFeatures() && Auth::user()->current_team_id)
In line 162:
- #if (Laravel\Jetstream\Jetstream::hasTeamFeatures())
+ #if (Laravel\Jetstream\Jetstream::hasTeamFeatures() && Auth::user()->current_team_id)
Fortify adds it's own auth routes, but old routes in config/auth.php will still be used (in my case)
Simple solution is to comment out all routes in config/auth.php (if using jetstream with fortify)
and run :
php artisan route:cache
this will make sure that auth routes use fortify actions, so each new account you create will have team created

Laravel Telescope is not working in production with Laravel Voyager. How to secure /telescope/* routes in Laravel 7?

I'm using Laravel with Auth, Auth UI, Voyager admin panel, Telescope. Everything works fine untill I change APP_ENV=local to APP_ENV=production in .env file. When I change the .env file to production then I get the below error. screen shot of my issue is here.
Trying to get property 'name' of non-object
Basically I want to protect /telescope/*routes in production. But before doing that I am getting this error.
I read the same issue in github similar issue github link. I think the answer is present in the link but im unable to digest it as im a newbie.
Any help to fix this, and protecting telescope routes in production is much appreciated. I tried to create a Policy and give read permissions to the user via policy. But somehow im not able to fix it.
ok: its too easy - the only thing you have to do is:
php artisan make:policy -m User UserPolicy
thats it.
You can pass the array of email into the gate method in the TelescopeServiceProvider.php
Gate::define('viewTelescope', function ($user) {
return in_array($user->email, [
'username#domain.com'
]);
});
This will block everyone except the mentioned email of logged-in user.

Laravel auth nothing happen when trying to login with default laravel auth page

I have previously transferred laravel from server to another by copying the laravel project folder, now when i try to login using default laravel auth page , if i enter wrong auth value i get error auth.failed
but when i enter a valid auth value the page refresh but nothing happen.
I notice from browser view source the value of CSRF token is changing one i enter the valid auth value
I tried to delete the session files /storage/framework/sessions
and tried
php artisan view:clear
php aritsan cache:clear
but nothing happen.
How can i fix this issue.
Use Laravel Debugbar for easily debugging such kind of cases.
It's good, simple and sweet ^
I fixed the issue.
In the previous server i was using SSL for my domain so the cookies setting in /config/session.php was true:-
'secure' => env('SESSION_SECURE_COOKIE', true),
Since, the current new server i am not using https when i open my website, so i set the value to false
'secure' => env('SESSION_SECURE_COOKIE', false),
Now everything working fine.

Laravel JWTAuth Custom User Model

I'm developing web using Laravel and JWTAuth with default user model at
App\User
Now i'm changin the path of my models to
App\Models
App\Models\User
and i change the jwt config to this
'user' => 'App\Models\User',
but when i try to access my login page, it's show error like this
FatalErrorException in EloquentUserProvider.php line 126:
Class 'App\User' not found
what happening with this? i've changing the setting to App\Models but it's still load to App\ directory?
I re-serve the php artisan, and do composer dump-autoload
It's the same error.
I've resolved my error,
there's one config called auth.php that must updated too
Thanks

Laravel 4 - changing resource root routing path

In a Laravel 4 installation, Using Jeffrey Way's Laravel 4 Generators, I set up a 'tweet' resource, using the scaffolding command from his example:
php artisan generate:scaffold tweet --fields="author:string, body:text"
This generated the model, view, controller, migration and routing information for the tweet type. After migrating the database, visiting http://localhost:8000/tweets works fine, and shows the expected content.
The contents of the routes.php file at this point is:
Route::resource('tweets', 'TweetsController');
Now I would like to move the url for tweets up one level into admin/tweets, so the above url should become: http://localhost:8000/admin/tweets. Please note that I am not treating 'Admin' as a resource, but instead just want to add it for hypothetical organizational purposes.
Changing the routes.php file to:
Route::resource('admin/tweets', 'TweetsController');
Does not work, and displays the following error:
Unable to generate a URL for the named route "tweets.create" as such route does not exist.
Similarly when using the following:
Route::group(array('prefix' => 'admin'), function() {
Route::resource('tweets', 'TweetsController');
});
As was suggested in this stackoverflow question.
Using php artisan routes reveals that the named routes also now have admin prefixed to them, turning tweets.create into admin.tweets.create.
Why is the error saying that it cannot find tweets.create? shouldn't that automatically be resolved (judging by the routes table), to use admin.tweets.create?
How can I change my routing so that this error no longer occurs?
I just tested with new resource controller and it works fine for me.
The problem is not with the Route, its with the named routes used in your application.
check your view files there are link to route like link_to_route('tweets.create', 'Add new tweet'), this is creating the error because when you add admin as prefix tweets.create doesn't exists so change it to admin.tweets.create every where, in your controller also where ever named route is used.

Resources