DarkGhostHunter / Laraguard

"On-premises 2FA Authentication for all your users out-of-the-box
MIT License
266 stars 24 forks source link

Invalid argument supplied for foreach() #26

Closed MazettePatacaisse closed 4 years ago

MazettePatacaisse commented 4 years ago

laravel version: 7.12

Facade\Ignition\Exceptions\ViewException Invalid argument supplied for foreach() (View: /resources/views/vendor/laraguard/auth.blade.php)

@foreach($credentials as $name => $value)

            <input type="hidden" name="{{ $name }}" value="{{ $value }}">

  @endforeach

This error appears when 2fa is activated on a successfull login request at the 2fa step

$credentials is empty.

DarkGhostHunter commented 4 years ago

I should add a fallback to an array.

DarkGhostHunter commented 4 years ago

Fixed in commit.

MazettePatacaisse commented 4 years ago

Ok thanks nut it's not the real problem. My problem is than $credentials should not be empty........ Normal work 1) User enter password/email 2) On successfull auth -> redirect to 2fa page with password/email credentials in hidden input.

Actually credentials not handle in hidden input. why ??

i have tested with creating 2 hidden input with credentials, and 2fa works great......

MazettePatacaisse commented 4 years ago

I've fixed temporarily like this in auth.blade wainting best solution.

@if( request()->has('email') &&  request()->has('password'))
            <input type="hidden" name="email" value="{{ request()->get('email') }}">
            <input type="hidden" name="password" value="{{ request()->get('password') }}">
        @endif

        @if( request()->has('remember'))
            <input type="hidden" name="remember" value="on">
        @endif
DarkGhostHunter commented 4 years ago

You should check your guard since the credentials are retrieved using the Attempt event.