Skip to content

Commit

Permalink
Merge pull request #39 from yparitcher/json
Browse files Browse the repository at this point in the history
Blade: use json_encode instead of @JSON
  • Loading branch information
Nielsvanpach authored Nov 7, 2024
2 parents 30f9a12 + b3d279f commit 4190e11
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion resources/views/loginLink.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<input type="hidden" name="key" value="{{ $key }}">
<input type="hidden" name="redirect_url" value="{{ $redirectUrl }}">
<input type="hidden" name="guard" value="{{ $guard }}">
<input type="hidden" name="user_attributes" value=@json($userAttributes)>
<input type="hidden" name="user_attributes" value="{{ json_encode($userAttributes) }}">

@include('login-link::loginLinkButton')
</form>
Expand Down
10 changes: 10 additions & 0 deletions tests/LoginLinkComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
assertMatchesHtmlSnapshot($html);
});

it('can render a login link with custom user attributes with a space from a variable', function () {
$role = 'senior admin';
$blade = <<<END
<x-login-link :user-attributes="['role' => '$role']" />'
END;
$html = Blade::render($blade);

assertMatchesHtmlSnapshot($html);
});

it('can render a login link with a specific redirect url', function () {
$html = Blade::render('<x-login-link redirect-url="{{ route(\'customUrlRouteName\') }}" />');

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html><body>
<form method="POST" action="http://localhost/laravel-login-link-login">
<input type="hidden" name="_token" value="" autocomplete="off">
<input type="hidden" name="email" value="">
<input type="hidden" name="key" value="">
<input type="hidden" name="redirect_url" value="">
<input type="hidden" name="guard" value="">
<input type="hidden" name="user_attributes" value='{"role":"senior admin"}'>

<button class="underline" type="submit">
Developer Login
</button>
</form>
'</body></html>

0 comments on commit 4190e11

Please sign in to comment.