Last active
September 5, 2019 12:23
-
-
Save SentryXSI/c243cb978096fcceb84ff0f1fa1f13ab to your computer and use it in GitHub Desktop.
Form Guard Ideas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use NinjaSentry\Katana\Form\Guard as FormGuard; | |
use NinjaSentry\Sai\Ui\Form\Builder as FormBuilder; | |
// Generator | |
$guard = (new FormGuard( $this->identity->session ) ) | |
->tokens() | |
->lockUri( $this->route->uri ) | |
->lockFields( | |
'axs_code', | |
FormGuard::FORM_TOKEN | |
); | |
$form = new FormBuilder( $guard ); | |
$form->open(); | |
$form->group() | |
->label('Code') | |
->input([ | |
'class' => 'form-control', | |
'name' => $form->field('axs_code'), | |
'id' => 'Code', | |
]); | |
$form->group() | |
->hidden([ | |
'name' => $form->field( $form->guard::FORM_TOKEN ), // Guard Key ( label ) | |
'value' => $form->guard->csrfToken, // Guard Value | |
]); | |
$form->submit([ | |
'class' => 'btn btn-danger', | |
'value' => 'Start Hard Drive Scan' | |
]); | |
$form->close(); | |
// Validator | |
(new FormGuard( | |
$this->identity->session | |
))->enforce( $this->route ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment