diff --git a/stubs/inertia-vue/resources/js/Pages/Auth/OAuth/Authorize.vue b/stubs/inertia-vue/resources/js/Pages/Auth/OAuth/Authorize.vue
index e3d10f9b9..b4c8b4214 100644
--- a/stubs/inertia-vue/resources/js/Pages/Auth/OAuth/Authorize.vue
+++ b/stubs/inertia-vue/resources/js/Pages/Auth/OAuth/Authorize.vue
@@ -5,10 +5,8 @@ import SecondaryButton from '@/Components/SecondaryButton.vue';
import { Head, Link, useForm } from '@inertiajs/vue3';
const props = defineProps({
- userName: String,
- userEmail: String,
- clientId: String,
- clientName: String,
+ user: Object,
+ client: Object,
scopes: Array,
state: String,
authToken: String,
@@ -17,7 +15,7 @@ const props = defineProps({
const form = useForm({
state: props.state,
- client_id: props.clientId,
+ client_id: props.client.id,
auth_token: props.authToken,
});
@@ -38,13 +36,13 @@ const deny = () => {
- {{ userName }}
+ {{ user.name }}
-
{{ userEmail }}
+
{{ user.email }}
- {{ clientName }} is requesting permission to access your account.
+ {{ client.name }} is requesting permission to access your account.
From f7725110358a5dbbae89763472660bc469e90f51 Mon Sep 17 00:00:00 2001
From: Hafez Divandari
Date: Sat, 3 Aug 2024 10:15:17 +0330
Subject: [PATCH 4/9] wip
---
src/Console/InstallCommand.php | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php
index 948718fc0..88baac91b 100644
--- a/src/Console/InstallCommand.php
+++ b/src/Console/InstallCommand.php
@@ -389,16 +389,18 @@ protected function afterPromptingForMissingArguments(InputInterface $input, Outp
));
}
+ if (in_array($stack, ['api', 'blade', 'react', 'vue'])) {
+ $input->setOption('oauth', confirm(
+ label: 'Would you like OAuth support via Laravel Passport?',
+ default: false
+ ));
+ }
+
$input->setOption('pest', select(
label: 'Which testing framework do you prefer?',
options: ['Pest', 'PHPUnit'],
default: $this->isUsingPest() ? 'Pest' : 'PHPUnit',
) === 'Pest');
-
- $input->setOption('oauth', confirm(
- label: 'Would you like OAuth support via Laravel Passport?',
- default: false
- ));
}
/**
From 79be7651912c94cbeca481a08ba40bd07854e09a Mon Sep 17 00:00:00 2001
From: Hafez Divandari
Date: Sat, 3 Aug 2024 10:18:30 +0330
Subject: [PATCH 5/9] wip
---
src/Console/InstallsInertiaStacks.php | 2 +-
.../resources/js/Pages/Auth/OAuth/Authorize.tsx | 4 ++--
.../resources/js/Pages/Auth/OAuth/Authorize.jsx | 9 +--------
.../resources/js/Pages/Auth/OAuth/Authorize.vue | 4 ++--
4 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/src/Console/InstallsInertiaStacks.php b/src/Console/InstallsInertiaStacks.php
index 543d240eb..c78e3aa9f 100644
--- a/src/Console/InstallsInertiaStacks.php
+++ b/src/Console/InstallsInertiaStacks.php
@@ -195,7 +195,7 @@ protected function installInertiaReactStack()
if (! $this->requireComposerPackages([
'inertiajs/inertia-laravel:^1.0',
$this->option('oauth') ? 'laravel/passport:^13.0' : 'laravel/sanctum:^4.0',
- 'tightenco/ziggy:^2.0'
+ 'tightenco/ziggy:^2.0',
])) {
return 1;
}
diff --git a/stubs/inertia-react-ts/resources/js/Pages/Auth/OAuth/Authorize.tsx b/stubs/inertia-react-ts/resources/js/Pages/Auth/OAuth/Authorize.tsx
index 4c91fcf95..b9d26fa71 100644
--- a/stubs/inertia-react-ts/resources/js/Pages/Auth/OAuth/Authorize.tsx
+++ b/stubs/inertia-react-ts/resources/js/Pages/Auth/OAuth/Authorize.tsx
@@ -12,8 +12,8 @@ export default function Authorize({
authToken,
promptLoginUrl,
}: {
- user: { name: string, email: string },
- client: { id: string, name: string },
+ user: { name: string; email: string },
+ client: { id: string; name: string },
scopes: { description: string }[],
state: string,
authToken: string,
diff --git a/stubs/inertia-react/resources/js/Pages/Auth/OAuth/Authorize.jsx b/stubs/inertia-react/resources/js/Pages/Auth/OAuth/Authorize.jsx
index 4c340eee2..0ab37bf57 100644
--- a/stubs/inertia-react/resources/js/Pages/Auth/OAuth/Authorize.jsx
+++ b/stubs/inertia-react/resources/js/Pages/Auth/OAuth/Authorize.jsx
@@ -3,14 +3,7 @@ import PrimaryButton from '@/Components/PrimaryButton';
import SecondaryButton from '@/Components/SecondaryButton';
import { Head, Link, useForm } from '@inertiajs/react';
-export default function Authorize({
- user,
- client,
- scopes,
- state,
- authToken,
- promptLoginUrl,
-}) {
+export default function Authorize({ user, client, scopes, state, authToken, promptLoginUrl }) {
const { post, processing, transform } = useForm({
state: state,
client_id: client.id,
diff --git a/stubs/inertia-vue-ts/resources/js/Pages/Auth/OAuth/Authorize.vue b/stubs/inertia-vue-ts/resources/js/Pages/Auth/OAuth/Authorize.vue
index 41cbb2fde..fc511af4a 100644
--- a/stubs/inertia-vue-ts/resources/js/Pages/Auth/OAuth/Authorize.vue
+++ b/stubs/inertia-vue-ts/resources/js/Pages/Auth/OAuth/Authorize.vue
@@ -5,8 +5,8 @@ import SecondaryButton from '@/Components/SecondaryButton.vue';
import { Head, Link, useForm } from '@inertiajs/vue3';
const props = defineProps<{
- user: { name: string, email: string };
- client: { id: string, name: string };
+ user: { name: string; email: string };
+ client: { id: string; name: string };
scopes: { description: string }[];
state: string;
authToken: string;
From 199774a9844a4fc2e786605bb80819e3b8d51ada Mon Sep 17 00:00:00 2001
From: Hafez Divandari
Date: Thu, 15 Aug 2024 01:17:49 +0330
Subject: [PATCH 6/9] wip
---
.../inertia-common/app/Providers/AppServiceProvider.php | 9 +--------
.../resources/js/Pages/Auth/OAuth/Authorize.tsx | 8 ++------
.../resources/js/Pages/Auth/OAuth/Authorize.jsx | 6 +++---
.../resources/js/Pages/Auth/OAuth/Authorize.vue | 6 ++----
.../resources/js/Pages/Auth/OAuth/Authorize.vue | 6 ++----
5 files changed, 10 insertions(+), 25 deletions(-)
diff --git a/stubs/inertia-common/app/Providers/AppServiceProvider.php b/stubs/inertia-common/app/Providers/AppServiceProvider.php
index 538a6a3fb..591596272 100644
--- a/stubs/inertia-common/app/Providers/AppServiceProvider.php
+++ b/stubs/inertia-common/app/Providers/AppServiceProvider.php
@@ -22,14 +22,7 @@ public function register(): void
public function boot(): void
{
Passport::authorizationView(function ($params) {
- return Inertia::render('Auth/OAuth/Authorize', [
- 'user' => $params['user'],
- 'client' => $params['client'],
- 'scopes' => $params['scopes'],
- 'state' => $params['request']->state,
- 'authToken' => $params['authToken'],
- 'promptLoginUrl' => $params['request']->fullUrlWithQuery(['prompt' => 'login']),
- ]);
+ return Inertia::render('Auth/OAuth/Authorize', $params);
});
}
}
diff --git a/stubs/inertia-react-ts/resources/js/Pages/Auth/OAuth/Authorize.tsx b/stubs/inertia-react-ts/resources/js/Pages/Auth/OAuth/Authorize.tsx
index b9d26fa71..9f54eedf0 100644
--- a/stubs/inertia-react-ts/resources/js/Pages/Auth/OAuth/Authorize.tsx
+++ b/stubs/inertia-react-ts/resources/js/Pages/Auth/OAuth/Authorize.tsx
@@ -8,19 +8,15 @@ export default function Authorize({
user,
client,
scopes,
- state,
authToken,
- promptLoginUrl,
}: {
user: { name: string; email: string },
client: { id: string; name: string },
scopes: { description: string }[],
- state: string,
authToken: string,
- promptLoginUrl: string,
}) {
const { post, processing, transform } = useForm({
- state: state,
+ state: route().params.state,
client_id: client.id,
auth_token: authToken,
});
@@ -81,7 +77,7 @@ export default function Authorize({
Log into another account
diff --git a/stubs/inertia-react/resources/js/Pages/Auth/OAuth/Authorize.jsx b/stubs/inertia-react/resources/js/Pages/Auth/OAuth/Authorize.jsx
index 0ab37bf57..2c3cd535d 100644
--- a/stubs/inertia-react/resources/js/Pages/Auth/OAuth/Authorize.jsx
+++ b/stubs/inertia-react/resources/js/Pages/Auth/OAuth/Authorize.jsx
@@ -3,9 +3,9 @@ import PrimaryButton from '@/Components/PrimaryButton';
import SecondaryButton from '@/Components/SecondaryButton';
import { Head, Link, useForm } from '@inertiajs/react';
-export default function Authorize({ user, client, scopes, state, authToken, promptLoginUrl }) {
+export default function Authorize({ user, client, scopes, authToken }) {
const { post, processing, transform } = useForm({
- state: state,
+ state: route().params.state,
client_id: client.id,
auth_token: authToken,
});
@@ -66,7 +66,7 @@ export default function Authorize({ user, client, scopes, state, authToken, prom
Log into another account
diff --git a/stubs/inertia-vue-ts/resources/js/Pages/Auth/OAuth/Authorize.vue b/stubs/inertia-vue-ts/resources/js/Pages/Auth/OAuth/Authorize.vue
index fc511af4a..3319e8a76 100644
--- a/stubs/inertia-vue-ts/resources/js/Pages/Auth/OAuth/Authorize.vue
+++ b/stubs/inertia-vue-ts/resources/js/Pages/Auth/OAuth/Authorize.vue
@@ -8,13 +8,11 @@ const props = defineProps<{
user: { name: string; email: string };
client: { id: string; name: string };
scopes: { description: string }[];
- state: string;
authToken: string;
- promptLoginUrl: string;
}>();
const form = useForm({
- state: props.state,
+ state: route().params.state,
client_id: props.client.id,
auth_token: props.authToken,
});
@@ -67,7 +65,7 @@ const deny = () => {
Log into another account
diff --git a/stubs/inertia-vue/resources/js/Pages/Auth/OAuth/Authorize.vue b/stubs/inertia-vue/resources/js/Pages/Auth/OAuth/Authorize.vue
index b4c8b4214..9632722a7 100644
--- a/stubs/inertia-vue/resources/js/Pages/Auth/OAuth/Authorize.vue
+++ b/stubs/inertia-vue/resources/js/Pages/Auth/OAuth/Authorize.vue
@@ -8,13 +8,11 @@ const props = defineProps({
user: Object,
client: Object,
scopes: Array,
- state: String,
authToken: String,
- promptLoginUrl: String,
});
const form = useForm({
- state: props.state,
+ state: route().params.state,
client_id: props.client.id,
auth_token: props.authToken,
});
@@ -67,7 +65,7 @@ const deny = () => {
Log into another account
From 9dbceb0759bffcfdda3376ccce81b8ce65467abe Mon Sep 17 00:00:00 2001
From: Hafez Divandari
Date: Thu, 15 Aug 2024 01:30:24 +0330
Subject: [PATCH 7/9] wip
---
.../resources/js/Pages/Auth/OAuth/Authorize.tsx | 2 +-
stubs/inertia-react/resources/js/Pages/Auth/OAuth/Authorize.jsx | 2 +-
.../inertia-vue-ts/resources/js/Pages/Auth/OAuth/Authorize.vue | 2 +-
stubs/inertia-vue/resources/js/Pages/Auth/OAuth/Authorize.vue | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/stubs/inertia-react-ts/resources/js/Pages/Auth/OAuth/Authorize.tsx b/stubs/inertia-react-ts/resources/js/Pages/Auth/OAuth/Authorize.tsx
index 9f54eedf0..bc6996f3e 100644
--- a/stubs/inertia-react-ts/resources/js/Pages/Auth/OAuth/Authorize.tsx
+++ b/stubs/inertia-react-ts/resources/js/Pages/Auth/OAuth/Authorize.tsx
@@ -77,7 +77,7 @@ export default function Authorize({
Log into another account
diff --git a/stubs/inertia-react/resources/js/Pages/Auth/OAuth/Authorize.jsx b/stubs/inertia-react/resources/js/Pages/Auth/OAuth/Authorize.jsx
index 2c3cd535d..cee4b1ff2 100644
--- a/stubs/inertia-react/resources/js/Pages/Auth/OAuth/Authorize.jsx
+++ b/stubs/inertia-react/resources/js/Pages/Auth/OAuth/Authorize.jsx
@@ -66,7 +66,7 @@ export default function Authorize({ user, client, scopes, authToken }) {
Log into another account
diff --git a/stubs/inertia-vue-ts/resources/js/Pages/Auth/OAuth/Authorize.vue b/stubs/inertia-vue-ts/resources/js/Pages/Auth/OAuth/Authorize.vue
index 3319e8a76..e05388988 100644
--- a/stubs/inertia-vue-ts/resources/js/Pages/Auth/OAuth/Authorize.vue
+++ b/stubs/inertia-vue-ts/resources/js/Pages/Auth/OAuth/Authorize.vue
@@ -65,7 +65,7 @@ const deny = () => {
Log into another account
diff --git a/stubs/inertia-vue/resources/js/Pages/Auth/OAuth/Authorize.vue b/stubs/inertia-vue/resources/js/Pages/Auth/OAuth/Authorize.vue
index 9632722a7..9abf5a5a5 100644
--- a/stubs/inertia-vue/resources/js/Pages/Auth/OAuth/Authorize.vue
+++ b/stubs/inertia-vue/resources/js/Pages/Auth/OAuth/Authorize.vue
@@ -65,7 +65,7 @@ const deny = () => {
Log into another account
From cca8c3fb47d5bfd065037ffcf1fcd91611e09a70 Mon Sep 17 00:00:00 2001
From: Hafez Divandari
Date: Fri, 6 Sep 2024 18:47:46 +0330
Subject: [PATCH 8/9] fix tests
---
stubs/inertia-common/app/Providers/AppServiceProvider.php | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/stubs/inertia-common/app/Providers/AppServiceProvider.php b/stubs/inertia-common/app/Providers/AppServiceProvider.php
index 6590e5cee..36cd57627 100644
--- a/stubs/inertia-common/app/Providers/AppServiceProvider.php
+++ b/stubs/inertia-common/app/Providers/AppServiceProvider.php
@@ -24,8 +24,10 @@ public function boot(): void
{
Vite::prefetch(concurrency: 3);
- Passport::authorizationView(function ($params) {
- return Inertia::render('Auth/OAuth/Authorize', $params);
- });
+ if (class_exists(Passport::class)) {
+ Passport::authorizationView(function ($params) {
+ return Inertia::render('Auth/OAuth/Authorize', $params);
+ });
+ }
}
}
From 70bb912174de8f135a550abd317166785ea73af1 Mon Sep 17 00:00:00 2001
From: Hafez Divandari
Date: Fri, 6 Sep 2024 18:51:02 +0330
Subject: [PATCH 9/9] formatting
---
stubs/inertia-common/app/Providers/AppServiceProvider.php | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/stubs/inertia-common/app/Providers/AppServiceProvider.php b/stubs/inertia-common/app/Providers/AppServiceProvider.php
index 36cd57627..6cc724db5 100644
--- a/stubs/inertia-common/app/Providers/AppServiceProvider.php
+++ b/stubs/inertia-common/app/Providers/AppServiceProvider.php
@@ -25,9 +25,7 @@ public function boot(): void
Vite::prefetch(concurrency: 3);
if (class_exists(Passport::class)) {
- Passport::authorizationView(function ($params) {
- return Inertia::render('Auth/OAuth/Authorize', $params);
- });
+ Passport::authorizationView(fn ($params) => Inertia::render('Auth/OAuth/Authorize', $params));
}
}
}