mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-27 13:45:29 +08:00
Two changes: - shows a more prominent warning when the "write" scope is requested - shows the application name when displaying the key <img width="600" alt="image" src="https://github.com/user-attachments/assets/79a6d906-532f-4f2d-bd7b-54bd70362728" /> <img width="600" alt="image" src="https://github.com/user-attachments/assets/08eec177-f43b-4280-8144-267b178bef7f" />
23 lines
826 B
Text
Vendored
23 lines
826 B
Text
Vendored
<p><%= t("user_api_key.instructions", application_name: @client.application_name) %></p>
|
|
<div class="user-api-key-display">
|
|
<code id="user-api-key-payload"><%= @payload %></code>
|
|
</div>
|
|
<div>
|
|
<button class="btn btn-primary" id="copy-api-key-btn">
|
|
<%= t("user_api_key.copy_key") %>
|
|
</button>
|
|
</div>
|
|
|
|
<script nonce="<%= csp_nonce_placeholder %>">
|
|
document.getElementById('copy-api-key-btn').addEventListener('click', function() {
|
|
const btn = this;
|
|
const payload = document.getElementById('user-api-key-payload').textContent.replace(/\s/g, '');
|
|
navigator.clipboard.writeText(payload).then(() => {
|
|
const originalText = btn.textContent;
|
|
btn.textContent = '<%= t("user_api_key.copied") %>';
|
|
setTimeout(() => {
|
|
btn.textContent = originalText;
|
|
}, 2000);
|
|
});
|
|
});
|
|
</script>
|