mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 16:15:13 +00:00
oauth manage cleanup
This commit is contained in:
parent
129072b0e5
commit
d27f9676b8
2 changed files with 23 additions and 13 deletions
|
@ -161,15 +161,26 @@ logger('redirect: ' . $redirect);
|
|||
}
|
||||
|
||||
|
||||
$r = q("SELECT oauth_clients.*, oauth_access_tokens.access_token as oauth_token, (oauth_clients.user_id = %d) AS my
|
||||
FROM oauth_clients
|
||||
LEFT JOIN oauth_access_tokens ON oauth_clients.client_id=oauth_access_tokens.client_id AND
|
||||
oauth_clients.user_id=oauth_access_tokens.user_id
|
||||
WHERE oauth_clients.user_id IN (%d,0)",
|
||||
intval(local_channel()),
|
||||
$r = q("SELECT * FROM oauth_clients WHERE user_id = %d ",
|
||||
intval(local_channel())
|
||||
);
|
||||
|
||||
|
||||
$c = q("select client_id, access_token from oauth_access_tokens where user_id = %d",
|
||||
intval(local_channel())
|
||||
);
|
||||
if ($r && $c) {
|
||||
foreach($c as $cv) {
|
||||
for($x = 0; $x < count($r); $x ++) {
|
||||
if($r[$x]['client_id'] === $cv['client_id']) {
|
||||
if(! array_key_exists($r[$x]['tokens'])) {
|
||||
$r[$x]['tokens'] = [];
|
||||
}
|
||||
$r[$x]['tokens'][] = $cv['access_token'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tpl = get_markup_template("settings_oauth2.tpl");
|
||||
$o .= replace_macros($tpl, array(
|
||||
'$form_security_token' => get_form_security_token("settings_oauth2"),
|
||||
|
|
|
@ -19,15 +19,14 @@
|
|||
<input type='hidden' name='name' value='{{$app.client_id}}'>
|
||||
<div class='oauthapp'>
|
||||
{{if $app.client_name}}<h4>{{$app.client_name}}</h4>{{else}}<h4>{{$noname}}</h4>{{/if}}
|
||||
{{if $app.my}}
|
||||
{{if $app.oauth_token}}
|
||||
<div class="settings-submit-wrapper" ><button class="settings-submit" type="submit" name="remove" value="{{$app.oauth_token}}">{{$remove}}</button></div>
|
||||
{{/if}}
|
||||
{{if $app.tokens}}
|
||||
{{foreach $app.tokens as $token}}
|
||||
<div class="settings-submit-wrapper" ><button class="settings-submit" type="submit" name="remove" value="{{$token}}">{{$remove}}</button></div>
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
{{if $app.my}}
|
||||
|
||||
<a href="{{$baseurl}}/settings/oauth2/edit/{{$app.client_id}}" title="{{$edit}}"><i class="fa fa-pencil btn btn-outline-secondary"></i></a>
|
||||
<a href="{{$baseurl}}/settings/oauth2/delete/{{$app.client_id}}?t={{$form_security_token}}" title="{{$delete}}"><i class="fa fa-trash-o btn btn-outline-secondary"></i></a>
|
||||
{{/if}}
|
||||
</div>
|
||||
</form>
|
||||
{{/foreach}}
|
||||
|
|
Loading…
Reference in a new issue