Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update instructions in README.md #17

Open
darkol opened this issue Jan 31, 2024 · 2 comments
Open

Update instructions in README.md #17

darkol opened this issue Jan 31, 2024 · 2 comments

Comments

@darkol
Copy link

darkol commented Jan 31, 2024

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 #8 (comment)

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
Copy link
Author

darkol commented Jan 31, 2024

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
Copy link
Author

darkol commented Feb 2, 2024

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 laravel/fortify#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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant