ln auth added

This commit is contained in:
Benjamin Takats
2022-12-01 19:44:29 +01:00
parent 9aae2f1a3f
commit 645599b7c6
27 changed files with 882 additions and 6 deletions

View File

@@ -1,5 +1,8 @@
<?php
use App\Models\LoginKey;
use App\Models\User;
use eza\lnurl;
use Illuminate\Support\Facades\Route;
/*
@@ -18,6 +21,38 @@ Route::get('/', function () {
})
->name('welcome');
Route::get('/auth/ln', \App\Http\Livewire\Auth\LNUrlAuth::class)
->name('auth.ln');
Route::get('/lnurl-auth-callback', function (\Illuminate\Http\Request $request) {
if (lnurl\auth($request->k1, $request->signature, $request->wallet_public_key)) {
// find User by $wallet_public_key
$user = User::where('public_key', $request->key)
->first();
if (!$user) {
// create User
$user = User::create([
'public_key' => $request->wallet_public_key,
'is_lecturer' => true,
]);
}
// check if $k1 is in the database, if not, add it
$loginKey = LoginKey::where('k1', $request->k1)
->first();
if (!$loginKey) {
LoginKey::create([
'k1' => $request->k1,
'user_id' => $user->id,
]);
}
return response()->json(['status' => 'OK']);
}
return response()->json(['status' => 'ERROR', 'reason' => 'Signature was NOT VERIFIED']);
})
->name('auth.ln.callback');
Route::get('/{country:code}/suche/stadt', \App\Http\Livewire\Frontend\SearchCity::class)
->name('search.city');