diff --git a/js/dist/admin.js b/js/dist/admin.js index c6c1a95..567e5fe 100644 Binary files a/js/dist/admin.js and b/js/dist/admin.js differ diff --git a/js/dist/admin.js.map b/js/dist/admin.js.map index 0e1f78d..b06d6b7 100644 Binary files a/js/dist/admin.js.map and b/js/dist/admin.js.map differ diff --git a/js/dist/forum.js b/js/dist/forum.js index 32fed37..125dc00 100644 Binary files a/js/dist/forum.js and b/js/dist/forum.js differ diff --git a/js/dist/forum.js.map b/js/dist/forum.js.map index 6c6b882..171efa9 100644 Binary files a/js/dist/forum.js.map and b/js/dist/forum.js.map differ diff --git a/js/src/admin/pages/ScopesPage.js b/js/src/admin/pages/ScopesPage.js index 3f807c0..3a137bb 100644 --- a/js/src/admin/pages/ScopesPage.js +++ b/js/src/admin/pages/ScopesPage.js @@ -82,7 +82,9 @@ export default class ScopesPage extends Page { className: 'Button Button--block', onclick: () => { const scope = app.store.createRecord('oauth-scopes'); - scope.save({}).then(this.scopes.push(scope)); + scope.save({ + 'scope': 'Scope.' + this.randomString(8), + }).then(this.scopes.push(scope)); }, }, app.translator.trans(this.translationPrefix + 'add_button')))), ]), @@ -92,7 +94,17 @@ export default class ScopesPage extends Page { ); } - + randomString(len) { + len = len || 8; + let $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + let maxPos = $chars.length; + let str = ''; + for (let i = 0; i < len; i++) { + //0~32的整数 + str += $chars.charAt(Math.floor(Math.random() * (maxPos + 1))); + } + return str; + } saveScopeInfo(index, key, value) { console.log(index, key, value); this.scopes[index].save({ diff --git a/src/Api/Controller/CreateScopeController.php b/src/Api/Controller/CreateScopeController.php index e679155..df0ef23 100644 --- a/src/Api/Controller/CreateScopeController.php +++ b/src/Api/Controller/CreateScopeController.php @@ -20,6 +20,8 @@ class CreateScopeController extends AbstractListController $attributes = Arr::get($request->getParsedBody(), 'data.attributes'); - return Scope::create([]); + return Scope::create([ + 'scope' => Arr::get($attributes, 'scope'), + ]); } }