fix: authorize

This commit is contained in:
FoskyM 2023-10-01 22:28:20 +08:00
parent 19a17bc851
commit 6e2aeffb43
No known key found for this signature in database
GPG key ID: 42C0ED6994AD7E9C
4 changed files with 17 additions and 12 deletions

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

@ -14,6 +14,7 @@ export default class AuthorizePage extends IndexPage {
client_scope = [];
loading = true;
is_authorized = false;
submit_loading = false;
oninit(vnode) {
super.oninit(vnode);
@ -166,14 +167,12 @@ export default class AuthorizePage extends IndexPage {
<input type="hidden" name="scope" value={this.params.scope}/>*/}
<input type="hidden" name="is_authorized" value={this.is_authorized}/>
<div style="display: flex; margin-top: 15px" class="oauth-form-item">
<Button className="Button" type="submit" style="width: 50%;" onclick={
this.is_authorized = false
}>
<Button className="Button" type="submit" style="width: 50%;" onclick={this.deny.bind(this)}
loading={this.submit_loading}>
{app.translator.trans('foskym-oauth-center.forum.authorize.deny')}
</Button>
<Button className="Button Button--primary" type="submit" style="width: 50%;" onclick={
this.is_authorized = true
}>
<Button className="Button Button--primary" type="submit" style="width: 50%;"
onclick={this.agree.bind(this)} loading={this.submit_loading}>
{app.translator.trans('foskym-oauth-center.forum.authorize.agree')}
</Button>
</div>
@ -187,6 +186,12 @@ export default class AuthorizePage extends IndexPage {
</div>
);
}
deny(e) {
this.is_authorized = false;
}
agree(e) {
this.is_authorized = true;
}
onsubmit(e) {
e.preventDefault();

View file

@ -45,7 +45,7 @@ class AuthorizeController implements RequestHandlerInterface
return new JsonResponse(json_decode($response->getResponseBody(), true));
}
$is_authorized = (Arr::get($params, 'authorized', 'no') === 'yes');
$is_authorized = Arr::get($params, 'is_authorized', 0);
$server->handleAuthorizeRequest($request, $response, $is_authorized, $actor->id);
if ($is_authorized) {
// this is only here so that you get to see your code in the cURL request. Otherwise, we'd redirect back to the client