fix(admin): create client

This commit is contained in:
FoskyM 2023-10-01 17:11:29 +08:00
parent 1985bd68ca
commit 6c537e4b80
No known key found for this signature in database
GPG key ID: 42C0ED6994AD7E9C
4 changed files with 18 additions and 3 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

@ -66,10 +66,12 @@ export default class ClientsPage extends Page {
className: 'Button Button--block',
onclick: () => {
const client = app.store.createRecord('oauth-clients');
const client_id = this.randomString(32);
const client_secret = this.randomString(32);
client.save({
client_id: this.randomString(32),
client_secret: this.randomString(32),
}).then(console.log);
client_id: client_id,
client_secret: client_secret,
}).then(this.clients.push(client));
// this.clients.push(Client.build({
//

View file

@ -15,4 +15,17 @@ use Flarum\Database\AbstractModel;
class Client extends AbstractModel
{
protected $table = 'oauth_clients';
protected $guarded = [];
public static function build(string $client_id, string $client_secret, int $user_id)
{
$client = new static();
$client->client_id = $client_id;
$client->client_secret = $client_secret;
$client->user_id = $user_id;
return $client;
}
}