Skip to content

Commit dba8a07

Browse files
committed
feat(user): blur api key in user settings
1 parent c023004 commit dba8a07

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

templates/user/settings.html

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,11 +829,32 @@ <h3 class="h5">
829829
<i class="fas fa-key"></i>
830830
</span>
831831
<span style="font-size: 90%;">
832-
<span style="user-select: all;">{{ .Subscription.ApiKey }}</span>
832+
<span id="user-api-key" style="user-select: all;" data-api-key="{{ .Subscription.ApiKey }}"> <span class="api-key-start" style="user-select: all;"></span><span class="api-key-middle" style="user-select: all; filter: blur(4px);"></span><span class="api-key-end" style="user-select: all;"></span> </span>
833833
<a style="color: #fff" id="copy-apiKey" data-toggle="tooltip" data-original-title="Copy API Key" data-clipboard-text="{{ .Subscription.ApiKey }}" class="btn btn-primary mb-1 btn-icon-inside">
834834
<span class="fa fa-copy icon-inside text-white"></span>
835835
</a>
836836
</span>
837+
<script>
838+
;(function () {
839+
var container = document.getElementById("user-api-key")
840+
if (!container) {
841+
return
842+
}
843+
var key = container.getAttribute("data-api-key") || ""
844+
if (!key) {
845+
return
846+
}
847+
var start = key.slice(0, 4)
848+
var end = key.slice(-4)
849+
var middle = key.slice(4, Math.max(4, key.length - 4))
850+
var startEl = container.querySelector(".api-key-start")
851+
var midEl = container.querySelector(".api-key-middle")
852+
var endEl = container.querySelector(".api-key-end")
853+
if (startEl) startEl.textContent = start
854+
if (midEl) midEl.textContent = middle
855+
if (endEl) endEl.textContent = end
856+
})()
857+
</script>
837858
</div>
838859
{{ else }}
839860
<div class="my-2">

0 commit comments

Comments
 (0)