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
Installation question #8
Comments
It means that you need to add this trend and code to the |
I edit "UserProfileScreen.php" and i add
|
@kaizirlewagen What are you missing is you need to use Basically the whole setup process is
composer require laravel/fortify
php artisan vendor:publish --provider="Laravel\Fortify\FortifyServiceProvider"
php artisan migrate
use Laravel\Fortify\TwoFactorAuthenticatable;
class User extends Authenticatable
{
use TwoFactorAuthenticatable;
}
composer require orchid/fortify
use Orchid\Screen\Screen;
use Orchid\Fortify\TwoFactorScreenAuthenticatable;
class UserProfileScreen extends Screen
{
use TwoFactorScreenAuthenticatable; // I guess this is where you've been stacked
public function commandBar(): iterable
{
return [
$this->twoFactorCommandBar(), // dropdown button
];
}
public function layout(): iterable
{
return [
// other layouts
$this->twoFactorLayout(), // modal and methods
];
}
}
Fortify provides some options - one of them is to confirm Two FA or not. You may find this within 'features' => [
Features::twoFactorAuthentication([
'confirm' => true, // confirm Two FA
'confirmPassword' => true, // confirm password to enable Two FA
]),
],
You may achieve this as you wish, I will show "my way"
use Orchid\Screen\Field;
use Orchid\Screen\Fields\Input;
use Orchid\Screen\Layouts\Rows;
class ProfileTwoFALayout extends Rows
{
protected function fields(): iterable
{
return [
Input::make('code'), // key should be named `code`. That's basically required minimum
];
}
}
class UserProfileScreen extends Screen
{
use TwoFactorScreenAuthenticatable; // I guess this is where you've been stacked
public function commandBar(): iterable
{
return [
$this->twoFactorCommandBar(), // dropdown button
];
}
public function layout(): iterable
{
return [
Layout::block(ProfileTwoFALayout::class)
->title(__('Confirm Two FA'))
->canSee(
auth()->user()->two_factor_secret && // show if authorized user has enabled Two FA
!auth()->user()->two_factor_confirmed_at // but still doesn't confirmed it
)
->commands(
Button::make(__('Confirm'))
->type(Color::PRIMARY())
->icon('check')
->action(route('two-factor.confirm')) // this route provided by Fortify and should not be changed
),
// other layouts
$this->twoFactorLayout(), // modal and methods
];
}
}
After hitting confirm you will be redirect back, and in your database you will see all three columns And that's it |
@czernika Amazing... thank you very much... i will try it today. 👍 |
@czernika Works perfect. Thx for your help 👍 |
I guess this should be added to README.md I have followed the procedure above, filling some more information:
Add
Fortify provides some options - one of them is to confirm Two FA or not. You may find this within
You may achieve this as you wish, I will show "my way" Create Layout for confirmation code in new file
Add Layout to your Screen in
As you can see I implemented After hitting PROBLEM: OK, I can add 2FA to the user that has at least main privilege to access admin panel to reach his User Profile Screen and I can see all three fields in the database populated, and |
Hi, i try to install and configure this module... but at the point
To use on the screen page, use the trait Orchid\Fortify\TwoFactorScreenAuthenticatable:
i don't know where i have to add this part.If i add it to my user edit view, i got this error:
Method App\Orchid\Screens\User\UserEditScreen::twoFactorCommandBar does not exist.
I am using Laravel 9 and Orchid 12, can you give me some informations how i can add 2fa?
The text was updated successfully, but these errors were encountered: