ln auth added

This commit is contained in:
Benjamin Takats
2022-12-01 19:49:24 +01:00
parent 5af2e34ff4
commit daa5d2e913
3 changed files with 32 additions and 32 deletions

View File

@@ -66,10 +66,10 @@
<a class="underline text-sm text-gray-600 hover:text-gray-900" href="{{ route('login') }}"> <a class="underline text-sm text-gray-600 hover:text-gray-900" href="{{ route('login') }}">
{{ __('Already registered?') }} {{ __('Already registered?') }}
</a> </a>
Wurde noch nicht implementiert
<x-jet-button class="ml-4"> {{--<x-jet-button class="ml-4">
{{ __('Register') }} {{ __('Register') }}
</x-jet-button> </x-jet-button>--}}
</div> </div>
</form> </form>
</x-jet-authentication-card> </x-jet-authentication-card>

View File

@@ -17,3 +17,32 @@ use Illuminate\Support\Facades\Route;
Route::middleware('auth:sanctum')->get('/user', function (Request $request) { Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user(); return $request->user();
}); });
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');

View File

@@ -24,35 +24,6 @@ Route::get('/', function () {
Route::get('/auth/ln', \App\Http\Livewire\Auth\LNUrlAuth::class) Route::get('/auth/ln', \App\Http\Livewire\Auth\LNUrlAuth::class)
->name('auth.ln'); ->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) Route::get('/{country:code}/suche/stadt', \App\Http\Livewire\Frontend\SearchCity::class)
->name('search.city'); ->name('search.city');