Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Invalid argument supplied for foreach() #26

Closed
MazettePatacaisse opened this issue May 27, 2020 · 5 comments
Closed

Invalid argument supplied for foreach() #26

MazettePatacaisse opened this issue May 27, 2020 · 5 comments

Comments

@MazettePatacaisse
Copy link

MazettePatacaisse commented May 27, 2020

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

I should add a fallback to an array.

@DarkGhostHunter
Copy link
Owner

Fixed in commit.

@MazettePatacaisse
Copy link
Author

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

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

DarkGhostHunter commented May 28, 2020

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

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

No branches or pull requests

2 participants