fortify icon indicating copy to clipboard operation
fortify copied to clipboard

Update instructions in README.md

Open darkol opened this issue 1 year ago • 2 comments

Please add the instructions on how to properly install and how to:

  • enable 2FA
  • use email verification on User registration

I find missing on how to acctually use the 2FA, after it is setup for the user? The user can login with only password and he is not asked for Authenticator code. See my comment https://github.com/orchidsoftware/fortify/issues/8#issuecomment-1918296743

Otherwise I find working great:

  • login user
  • register new user
  • sending email on forgoten password request with password update token (link) But I can not figure out how to use email verification e.g. email confirmation for newly registered user, before he can login

I tried to follow https://laracasts.com/discuss/channels/laravel/sending-the-confirmation-e-mail-when-using-fortify-for-the-auth-functions.

I have enabled by default disabled feature emailVerification in config\fortify.ph

    'features' => [
        Features::registration(),
        Features::resetPasswords(),
        Features::emailVerification(),
        Features::updateProfileInformation(),
        Features::updatePasswords(),
        Features::twoFactorAuthentication([
            'confirm' => true,
            'confirmPassword' => true,
            // 'window' => 0,
        ]),
    ],

I have added use Illuminate\Contracts\Auth\MustVerifyEmail; to app\Models\User.php

<?php

namespace App\Models;

use Laravel\Fortify\TwoFactorAuthenticatable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Orchid\Filters\Types\Like;
use Orchid\Filters\Types\Where;
use Orchid\Filters\Types\WhereDateStartEnd;
use Orchid\Platform\Models\User as Authenticatable;

class User extends Authenticatable
{
	use TwoFactorAuthenticatable;

....

darkol avatar Jan 31 '24 03:01 darkol

For the Verfication Email to work I found out on https://laracasts.com/discuss/channels/laravel/sending-the-confirmation-e-mail-when-using-fortify-for-the-auth-functions

I need to update

class User extends Authenticatable

to

class User extends Authenticatable implements MustVerifyEmail

in app\Models\User.php

darkol avatar Jan 31 '24 13:01 darkol

Finally, solved (as I am new to Laravel) the remaining problem with the Two Factor Challenge not trigerring :)

It seems besides not adequate documentation of orchid/fortify, there is also a missing instruction in laravel/fortify, that might be not mandatory for Laravel Fortify masters, but for beginers is a a total waste of time, as after a few days I almost do not know where my head sticks as I have tried so many tutorials, example app snippets in the code, that I get hard to cleanup the mess :D

So, it all comes to this https://github.com/laravel/fortify/issues/305 I had to copy code from vendor\laravel\fortify\src\Http\Controllers\AuthenticatedSessionController.php to app\Http\Controllers\Auth\AuthenticatedSessionController.php, where I only keept namespace line.

Maybe I could include code from vendor\laravel\fortify\src\Http\Controllers\AuthenticatedSessionController.php in some more convenient and proper way, other then copying its code ?!

Finally, after login with Authentication code, I got Error 400 routing me to /home, that was fixed by updating config/fortify.php where home needs to be set to /dashboard as it seems the Foritfy does not use global HOME variable that is set by Orchid I guess?

 /*
    |--------------------------------------------------------------------------
    | Home Path
    |--------------------------------------------------------------------------
    |
    | Here you may configure the path where users will get redirected during
    | authentication or password reset when the operations are successful
    | and the user is authenticated. You are free to change this value.
    |
    */

    'home' => '/dashboard',

When I clean up the mess in files I made and repeat the fresh install, I can provide diff or try to branch/commit updates to orchid/fortify?

darkol avatar Feb 02 '24 11:02 darkol