Merge pull request 'ranjith-dev' (#164) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #164
This commit was merged in pull request #164.
This commit is contained in:
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
const vapidKey = "{{ config('webpush.vapid.public_key') }}";
|
const vapidKey = "{{ config('webpush.vapid.public_key') }}";
|
||||||
// const csrfToken = "{{ csrf_token() }}";
|
const csrfToken = "{{ csrf_token() }}";
|
||||||
|
|
||||||
async function registerPush() {
|
async function registerPush() {
|
||||||
if (!('serviceWorker' in navigator)) return;
|
if (!('serviceWorker' in navigator)) return;
|
||||||
@@ -57,11 +57,11 @@
|
|||||||
applicationServerKey: vapidKey
|
applicationServerKey: vapidKey
|
||||||
});
|
});
|
||||||
|
|
||||||
await fetch('/api/push/subscribe', {
|
await fetch('/push/subscribe', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
// 'X-CSRF-TOKEN': csrfToken
|
'X-CSRF-TOKEN': csrfToken
|
||||||
},
|
},
|
||||||
body: JSON.stringify(subscription)
|
body: JSON.stringify(subscription)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -58,30 +58,30 @@ use App\Http\Livewire\CustomLogin;
|
|||||||
'keys.auth' => 'required|string',
|
'keys.auth' => 'required|string',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// WebPushSubscription::updateOrCreate(
|
|
||||||
// ['endpoint' => $request->endpoint],
|
|
||||||
// [
|
|
||||||
// 'subscribable_type' => get_class($user),
|
|
||||||
// 'subscribable_id' => $user->id,
|
|
||||||
// 'public_key' => $request->keys['p256dh'],
|
|
||||||
// 'auth_token' => $request->keys['auth'],
|
|
||||||
// 'content_encoding' => $request->contentEncoding ?? 'aesgcm',
|
|
||||||
// ]
|
|
||||||
// );
|
|
||||||
|
|
||||||
WebPushSubscription::updateOrCreate(
|
WebPushSubscription::updateOrCreate(
|
||||||
|
['endpoint' => $request->endpoint],
|
||||||
[
|
[
|
||||||
'endpoint' => $request->endpoint,
|
|
||||||
'subscribable_type' => get_class($user),
|
'subscribable_type' => get_class($user),
|
||||||
'subscribable_id' => $user->id,
|
'subscribable_id' => $user->id,
|
||||||
],
|
|
||||||
[
|
|
||||||
'public_key' => $request->keys['p256dh'],
|
'public_key' => $request->keys['p256dh'],
|
||||||
'auth_token' => $request->keys['auth'],
|
'auth_token' => $request->keys['auth'],
|
||||||
'content_encoding' => $request->contentEncoding ?? 'aesgcm',
|
'content_encoding' => $request->contentEncoding ?? 'aesgcm',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// WebPushSubscription::updateOrCreate(
|
||||||
|
// [
|
||||||
|
// 'endpoint' => $request->endpoint,
|
||||||
|
// 'subscribable_type' => get_class($user),
|
||||||
|
// 'subscribable_id' => $user->id,
|
||||||
|
// ],
|
||||||
|
// [
|
||||||
|
// 'public_key' => $request->keys['p256dh'],
|
||||||
|
// 'auth_token' => $request->keys['auth'],
|
||||||
|
// 'content_encoding' => $request->contentEncoding ?? 'aesgcm',
|
||||||
|
// ]
|
||||||
|
// );
|
||||||
|
|
||||||
|
|
||||||
return response()->json(['success' => true]);
|
return response()->json(['success' => true]);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user