feat(extend): clients

This commit is contained in:
FoskyM 2023-09-29 22:25:55 +08:00
parent 5a8ea7f751
commit 54e7659d9f
No known key found for this signature in database
GPG key ID: 42C0ED6994AD7E9C
9 changed files with 25 additions and 6 deletions

View file

@ -27,6 +27,8 @@ return [
(new Extend\Routes('forum'))
->post('/oauth/authorize', 'oauth.authorize.post', Controllers\AuthorizeController::class),
(new Extend\Routes('api'))
->get('/oauth/clients', 'oauth.clients.list', Api\Controller\ListClientController::class),
(new Extend\Middleware('api'))->add(ResourceScopeMiddleware::class),
];

BIN
js/dist/admin.js generated vendored

Binary file not shown.

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

Binary file not shown.

BIN
js/dist/forum.js generated vendored

Binary file not shown.

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

Binary file not shown.

View file

@ -7,7 +7,7 @@ export default class ClientsPage extends Page {
oninit(vnode) {
super.oninit(vnode);
app.store.find('clients').then(() => {
app.store.find('oauth/clients').then(() => {
m.redraw();
});
}

7
js/src/common/extend.js Normal file
View file

@ -0,0 +1,7 @@
import Extend from 'flarum/common/extenders';
import Client from "./models/Client";
export default [
new Extend.Store()
.add('oauth-clients', Client),
];

View file

@ -1,5 +1 @@
import app from 'flarum/common/app';
app.initializers.add('foskym/flarum-oauth-center', () => {
console.log('[foskym/flarum-oauth-center] Hello, forum and admin!');
});
export { default as extend } from './extend';

View file

@ -0,0 +1,14 @@
import Model from 'flarum/common/Model';
export default class Client extends Model {
client_id = Model.attribute('client_id');
client_secret = Model.attribute('client_secret');
redirect_uri = Model.attribute('redirect_uri');
grant_types = Model.attribute('grant_types');
scope = Model.attribute('scope');
user_id = Model.attribute('user_id');
client_name = Model.attribute('client_name');
client_icon = Model.attribute('client_icon');
client_desc = Model.attribute('client_desc');
client_home = Model.attribute('client_home');
}