Skip to content

Commit

Permalink
feat: add crddentials to url to directly login
Browse files Browse the repository at this point in the history
  • Loading branch information
flemming-pr committed Aug 2, 2023
1 parent dfc5afc commit dd05f9a
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

AUTO_LOGIN_CREDENTIALS=
5 changes: 5 additions & 0 deletions app/Models/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ public function transactions(): HasMany
{
return $this->hasMany(Transaction::class);
}

public function getAutoLoginLink(): string
{
return str_replace('://', '://' . config('app.autoLoginCredentials') . '@', route('item.show', $this->id));
}
}
2 changes: 2 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

return [

'autoLoginCredentials' => env('AUTO_LOGIN_CREDENTIALS', null),

/*
|--------------------------------------------------------------------------
| Application Name
Expand Down
1 change: 1 addition & 0 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function run(): void
{
$this->call([
ItemSeeder::class,
UserSeeder::class,
]);
}
}
23 changes: 23 additions & 0 deletions database/seeders/UserSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Database\Seeders;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\User;

class UserSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
User::create([
'name' => 'Admin',
'email' => '[email protected]',
'password' => bcrypt('Schnell33'),
'is_admin' => true,
]);
}
}
10 changes: 4 additions & 6 deletions resources/views/templates/item/print.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
<body class="absolute w-[62mm] hyphens-auto">
<h1 class="text-lg">Chaostreff Flensburg</h1>
<h2 class="text-xl">{{ $item->name }}</h2>
<p>Zum Ausleihen scannen</p>
<img src="https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl={{ route('item.show', $item->id) }}&choe=UTF-8" alt="barcode" />
<img src="https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl={{ $item->getAutoLoginLink() }}&choe=UTF-8" alt="barcode" />
<p>{{ route('item.show', $item->id) }}</p>
<p>
User: [email protected]<br>
Passwort: Schnell33
</p>
<strong>
Item Id: {{ $item->id }}
</strong>

<p class="mt-16 print:hidden">Zum drucken mit dem Label Drucker in max 62mm breite drucken. Einfach diese Seite drucken.</p>
</body>
Expand Down

0 comments on commit dd05f9a

Please sign in to comment.