Merge pull request #87 from simple-login/show-hide-api-key

Show hide api key
This commit is contained in:
Son Nguyen Kim 2020-02-19 23:55:39 +07:00 committed by GitHub
commit 6486d4dd6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 7 deletions

View file

@ -19,11 +19,12 @@
You can install the Chrome extension on
<a href="https://chrome.google.com/webstore/detail/simplelogin-extension/dphilobhebphkdjbpfohgikllaljmgbn"
target="_blank">Chrome Store<i class="fe fe-external-link"></i></a>,
Firefox add-on on <a href="https://addons.mozilla.org/en-GB/firefox/addon/simplelogin/" target="_blank">Firefox<i
class="fe fe-external-link"></i></a>
and Safari extension on <a
href="https://apps.apple.com/us/app/simplelogin/id1494051017?mt=12&fbclid=IwAR0M0nnEKgoieMkmx91TSXrtcScj7GouqRxGgXeJz2un_5ydhIKlbAI79Io"
target="_blank">AppStore<i class="fe fe-external-link"></i></a>
Firefox add-on on <a href="https://addons.mozilla.org/en-GB/firefox/addon/simplelogin/"
target="_blank">Firefox<i
class="fe fe-external-link"></i></a>
and Safari extension on <a
href="https://apps.apple.com/us/app/simplelogin/id1494051017?mt=12&fbclid=IwAR0M0nnEKgoieMkmx91TSXrtcScj7GouqRxGgXeJz2un_5ydhIKlbAI79Io"
target="_blank">AppStore<i class="fe fe-external-link"></i></a>
<br>
Please copy and paste the API key below into the extension to get started. <br>
<span class="text-danger">
@ -44,7 +45,16 @@
{% endif %}
</h6>
<input class="form-control w-100" id="apikey-{{ api_key.id }}" readonly value="**********">
<div class="input-group">
<input class="form-control" id="apikey-{{ api_key.id }}" readonly value="**********">
<div class="input-group-append">
<span class="input-group-text">
<i class="fe fe-eye toggle-api-key" data-show="off" data-secret="{{ api_key.code }}"
></i>
</span>
</div>
</div>
<br>
<div class="row">
@ -105,5 +115,23 @@
}
});
});
$(".toggle-api-key").on('click', function (event) {
let that = $(this);
let apiInput = that.parent().parent().parent().find("input");
if (that.attr("data-show") === "off") {
let apiKey = $(this).attr("data-secret");
apiInput.val(apiKey);
that.addClass("fe-eye-off");
that.removeClass("fe-eye");
that.attr("data-show", "on");
} else {
that.removeClass("fe-eye-off");
that.addClass("fe-eye");
apiInput.val("**********");
that.attr("data-show", "off");
}
});
</script>
{% endblock %}

View file

@ -151,7 +151,10 @@ def fake_data():
db.session.commit()
api_key = ApiKey.create(user_id=user.id, name="Chrome")
api_key.code = "code"
api_key.code = "codeCH"
api_key = ApiKey.create(user_id=user.id, name="Firefox")
api_key.code = "codeFF"
GenEmail.create_new(user.id, "e1@")
GenEmail.create_new(user.id, "e2@")