Comments (17)
Here's a simple workaround if you need to implement it right now. However I would too absolutely prefer much more cleaner solution, such as adding new dedicated config key would be the easiest implementation, but for now this should do.
Add new config key in config/fortify.php
'registered' => '/onboarding',
or you could also make it use RouteServiceProvider
const
// app/providers/RouteServiceProvider.php
public const REGISTERED_REDIRECT = '/onboarding'
// app/config/fortify.php
'registered' => App\Provider\RouteServiceProvider::REGISTERED_REDIRECT,
Create new class App\Responses\RegisterResponse
<?php
namespace App\Responses;
use Illuminate\Http\Response;
use Laravel\Fortify\Contracts\RegisterResponse as RegisterResponseContract;
class RegisterResponse implements RegisterResponseContract
{
public function toResponse($request)
{
return $request->wantsJson()
? new Response('', 201)
: redirect(config('fortify.registered'));
}
}
Bind new interface implementation inside FortifyServiceProvider.php
use App\Responses\RegisterResponse;
use Laravel\Fortify\Contracts\RegisterResponse as RegisterResponseContract;
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->bind(
RegisterResponseContract::class,
RegisterResponse::class
);
}
from fortify.
Hi There Add This To The Route File It Should Work.
Route::get('/login',function(){
return redirect()->route('index');
})->name('login');
from fortify.
Ya lo solucione ....
en el archivo RouteServiceProvider.php escribi esta linea
public const LOGOUT_REDIRECT = '/login'; <------ que redirecciona al login
luego en el archivo fortify.php la mande a llamar con el nombre 'salir'
luego cree una carpeta llamada Responses dentro de la carpeta app. Ahí cree un archivo llamado LogoutResponse.php y en ese archivo mande a llamar a la constante (no me queda claro si es constante o variable) con el nombre salir
from fortify.
Using Laravel v8.9.0, On top of RouteServiceProvider:
/**
* The path to the "home" route for your application.
*
* This is used by Laravel authentication to redirect users after login.
*
* @var string
*/
public const HOME = '/';
from fortify.
Feel free to send a PR.
from fortify.
@c0nst4ntin that's exactly what @nadhifikbarw's suggestion above accomplishes, simply create a response class and bind this to the container as the Fortify register response.
from fortify.
Hello, I would like to know how I can do to customize the redirection after logging out.
I see that by default it redirects you to the index of your project, I don't like that .. please help
from fortify.
Custom redirection has been handled, see https://laracasts.com/discuss/channels/laravel/version-8-redirects
That was resolved immediately when laravel version 8 came out.
from fortify.
i think its not like that
from fortify.
@jonasvanderhaegen this is okay for certain use cases. But imagine I wanted to customize further, e.g. redirect to a variable path after profile update (imagine -> profile/MyNewUserName)
from fortify.
+1 for this feature request
from fortify.
I'm not too familiar with this, but couldn't publishing single response classes or controllers and then having the possibility to overwrite these work? If so, is there a way?
from fortify.
@betopicapiedra You could use the same method like my previous suggestion, but instead of rebinding the RegisterResponse
contract, rebind the LogoutResponse
contract instead.
from fortify.
I already did what you suggested but it doesn't work
@nadhifikbarw
from fortify.
In the pull request implemented the possibility to perform some action after the user registers
Now it is only necessary to implement the afterRegister() method in the App\Actions\Fortify\CreatesNewUsers Class and what is in it will be executed after registration.
from fortify.
@betopicapiedra Please use English so it's easier for everyone, but assuming from your screenshot, you haven't bind your LogoutResponse
implementation with LogoutResponseContract
via FortifyServiceProvider
from fortify.
Ya esta solucionado ....gracias ...
It is already resolved, thank you ...
from fortify.
Related Issues (20)
- Laravel 10.10 - Cast password "hashed" HOT 3
- login limiter doesn't work actually HOT 1
- When Session based Guard is not used Logout fails HOT 3
- Integrate Precognition Into Fortify Route HOT 1
- Route [logout] not defined after changing the app_env from local to production
- Without override the PasswordResetLinkController@store we cannot add reCAPTCHA HOT 1
- Name all routes for Ziggy support when enableViews is false HOT 2
- Paths override with dot in route name does not work HOT 3
- Fortify http request methods for routes requiring multipart/form-data HOT 1
- Support for laravel passport HOT 2
- Provide "Don't ask me again on this computer" feature HOT 3
- Implementation for ActivityLogs HOT 1
- Custom Rate Limiter HOT 1
- Confusion between the username/email field in the database and the username/email field in the request (form) HOT 4
- No error message on expired token HOT 4
- Can we get a way to add additional validation rules to LoginRequest?
- A proposal for Fortify 2.0 HOT 4
- Used password reset link still valid to change password again HOT 1
- RegisterViewResponse is not instantiable. HOT 3
- How to disable setting up Google Authenticator for a certain user 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 fortify.