Add reset token button (#1755)

Closes #696
This commit is contained in:
qwerty287 2023-05-14 18:48:33 +02:00 committed by GitHub
parent 1f9d943564
commit 02913fa7b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View file

@ -432,6 +432,7 @@
"api_usage": "Example API Usage",
"cli_usage": "Example CLI Usage",
"dl_cli": "Download CLI",
"shell_setup_before": "do shell setup steps before"
"shell_setup_before": "do shell setup steps before",
"reset_token": "Reset token"
}
}

View file

@ -289,6 +289,10 @@ export default class WoodpeckerClient extends ApiClient {
return this._delete(`/api/users/${user.login}`);
}
resetToken(): Promise<string> {
return this._delete('/api/user/token') as Promise<string>;
}
// eslint-disable-next-line promise/prefer-await-to-callbacks
on(callback: (data: { pipeline?: Pipeline; repo?: Repo; step?: PipelineStep }) => void): EventSource {
return this._subscribe('/stream/events', callback, {

View file

@ -6,7 +6,10 @@
<SelectField v-model="selectedLocale" :options="localeOptions" />
<div>
<h2 class="text-lg text-color">{{ $t('user.token') }}</h2>
<div class="flex items-center mb-2">
<h2 class="text-lg text-color">{{ $t('user.token') }}</h2>
<Button class="ml-4" :text="$t('user.reset_token')" @click="resetToken" />
</div>
<pre class="cli-box">{{ token }}</pre>
</div>
@ -90,6 +93,11 @@ const selectedLocale = computed<string>({
return storedLocale.value;
},
});
const resetToken = async () => {
token.value = await apiClient.resetToken();
window.location.href = `${address}/logout`;
};
</script>
<style scoped>