forked from Kyon147/laravel-shopify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoken.blade.php
64 lines (56 loc) · 2.49 KB
/
token.blade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
@extends('shopify-app::layouts.default')
@section('styles')
@include('shopify-app::partials.polaris_skeleton_css')
@endsection
@section('content')
<div>
<div class="Polaris-SkeletonPage__Page" role="status" aria-label="Page loading">
<div class="Polaris-SkeletonPage__Header">
<div class="Polaris-SkeletonPage__TitleAndPrimaryAction">
<div class="Polaris-SkeletonPage__TitleWrapper">
<div class="Polaris-SkeletonPage__SkeletonTitle"></div>
</div>
</div>
</div>
<div class="Polaris-SkeletonPage__Content">
<div class="Polaris-Layout">
<div class="Polaris-Layout__Section">
<div class="Polaris-Card">
<div class="Polaris-Card__Section">
<div class="Polaris-SkeletonBodyText__SkeletonBodyTextContainer">
<div class="Polaris-SkeletonBodyText"></div>
<div class="Polaris-SkeletonBodyText"></div>
<div class="Polaris-SkeletonBodyText"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@section('scripts')
@parent
<script>
// If no host is found, we need to throw an error
const host = new URLSearchParams(location.search).get("host");
if (!host) {
throw new Error('No host found in the URL');
}
// If shopify is not defined, then we are not in a Shopify context redirect to the homepage as it
if (typeof shopify === 'undefined') {
open("{{ route('home') }}", "_self");
}
shopify.idToken().then((token) => {
let url = new URL(`{!! $target !!}`, window.location.origin);
// Enforce HTTPS if the current page is using HTTPS
if (window.location.protocol === 'https:') {
url.protocol = 'https:';
}
url.searchParams.set('token', token);
url.searchParams.set('host', host);
open(url.toString(), "_self");
history.pushState(null, '', url.toString());
});
</script>
@endsection