feat: add default scope

This commit is contained in:
FoskyM 2023-10-02 05:57:49 +08:00
parent a92398ca8d
commit ca160ae8eb
No known key found for this signature in database
GPG key ID: 42C0ED6994AD7E9C
4 changed files with 37 additions and 4 deletions

BIN
js/dist/admin.js generated vendored

Binary file not shown.

BIN
js/dist/admin.js.map generated vendored

Binary file not shown.

View file

@ -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,

View file

@ -0,0 +1,32 @@
<?php
/*
* This file is part of foskym/flarum-oauth-center.
*
* Copyright (c) 2023 FoskyM.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;
return [
'up' => 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) {
},
];