From ca160ae8ebd7040f60c05cdebb0552de6514f897 Mon Sep 17 00:00:00 2001 From: FoskyM Date: Mon, 2 Oct 2023 05:57:49 +0800 Subject: [PATCH] feat: add default scope --- js/dist/admin.js | Bin 10758 -> 10967 bytes js/dist/admin.js.map | Bin 32185 -> 32671 bytes js/src/admin/pages/ScopesPage.js | 9 ++--- ...d_default_record_to_oauth_scopes_table.php | 32 ++++++++++++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 migrations/2023_10_02_add_default_record_to_oauth_scopes_table.php diff --git a/js/dist/admin.js b/js/dist/admin.js index 4431dad9559beeba7b65eae039647b2d7b21b787..d45ab951e49994f9979fc42cdff021044c6ec29b 100644 GIT binary patch delta 359 zcmZn*xgNTKmqQ@lwnQ&aqfFB}IX|zsL?L~0Jcs&Z7Y;$j^vz)$pEwxfH+u@+V`q$? zd{$Cpa)4wFP~fa&JeyfcW^rOtPHKvkl73=ArhaL0YLSwyt!=7aQEG91X;E@&d_iJK zhK8n^no@3RNk)DONH%|Rzk=jsH$|bzVG34OBp8ud9G{Y!mROoo0yAd5EeYCD+ypZL zGPl}!DC@V{YY1yIyT*S; E05@}b`~Uy| delta 143 zcmcZ}+7_~bmqQ@kwnQ&aqfFB}IX|zsL?M21Jcs&Z7Y;$j_|0J)pEwxPH+u@+V`ogC zd{$Cpa)4wFP~fa&JlkX@MTyDP3O+!3-sJld(v#~H_$PBo%EA@uPoAgb4d$h74p7c! Y1~U~V-%&dcWt~xf4PkA*q4A#)0C}e}fdBvi diff --git a/js/dist/admin.js.map b/js/dist/admin.js.map index 7406db647646b63ec2f40ef59b387c5b3e5836ef..21de8ca152871911b1fc02799a8a5e0dc4c8c62f 100644 GIT binary patch delta 1350 zcmbtS%}*0S6whL!9K;J)6liHnTNEZjfkJB}=FRN3EVZl(r5Y2Zv&~s!W zvB(UFv>x_!9vZTAHV;q{EC&$gQ*ovNqzqQ%0Aqq>04|qQc_ubg+;;c0NA1GgO?>YT z9v{`24)SAZfHG$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age.js @@ -50,11 +50,13 @@ export default class ScopesPage extends Page { 'PATCH': 'PATCH', }, value: scope[key]() || 'GET', + disabled: scope.resource_path() === '/api/user' && key === 'method', onchange: (value) => { this.saveScopeInfo(index, key, value); }, }) : key === 'is_default' ? Checkbox.component({ state: scope[key]() === 1 || false, + disabled: scope.resource_path() === '/api/user' && key === 'is_default', onchange: (checked) => { this.scopes[index].is_default((this.scopes[index].is_default() + 1) % 2) this.saveScopeInfo(index, key, checked ? 1 : 0); @@ -62,21 +64,20 @@ export default class ScopesPage extends Page { }) : m('input.FormControl', { type: 'text', value: scope[key]() || '', + disabled: scope.resource_path() === '/api/user' && key === 'resource_path', onchange: (event) => { - this.saveScopeInfo(index, key, event.target.value); }, })) ), - m('td', Button.component({ + (scope.resource_path() !== '/api/user' && m('td', Button.component({ className: 'Button Button--icon', icon: 'fas fa-times', onclick: () => { this.scopes[index].delete(); this.scopes.splice(index, 1); - }, - })), + }))), ])), m('tr', m('td', { colspan: 7, diff --git a/migrations/2023_10_02_add_default_record_to_oauth_scopes_table.php b/migrations/2023_10_02_add_default_record_to_oauth_scopes_table.php new file mode 100644 index 0000000..bda0bc2 --- /dev/null +++ b/migrations/2023_10_02_add_default_record_to_oauth_scopes_table.php @@ -0,0 +1,32 @@ + function (Builder $schema) { + if (!$schema->hasTable('oauth_scopes')) { + return; + } + $schema->getConnection()->table('oauth_scopes')->insert([ + 'scope' => 'user.read', + 'resource_path' => '/api/user', + 'method' => 'GET', + 'is_default' => 1, + 'scope_name' => '获取用户信息', + 'scope_icon' => 'fas fa-user', + 'scope_desc' => '访问该用户({user})的个人信息等', + ]); + }, + 'down' => function (Builder $schema) { + + }, +];