mirror of
https://github.com/grocy/grocy.git
synced 2025-08-18 03:25:50 +00:00
Apikeys (#986)
* Add QR-Code for API-Url/Key * Show only API-Keys for current user * Allow only admin users to create custom API-Keys * Use a managed package of qrcode-generator instead of a copy of the JS file * Reuse existing localization string (API key) * Center QR-Code in popups Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
committed by
GitHub
parent
40f379b761
commit
85a95f1973
@@ -175,3 +175,19 @@ function animateCSS(selector, animationName, callback, speed = "faster")
|
||||
function RandomString() {
|
||||
return Math.random().toString(36).substring(2, 100) + Math.random().toString(36).substring(2, 100);
|
||||
}
|
||||
function getQRCodeForContent(url)
|
||||
{
|
||||
var qr = qrcode(0, 'L');
|
||||
qr.addData(url);
|
||||
qr.make();
|
||||
return qr.createImgTag(10, 5);
|
||||
}
|
||||
function getQRCodeForAPIKey(apikey_type, apikey_key)
|
||||
{
|
||||
var content = U('/api') + '|' + apikey_key;
|
||||
if(apikey_type === 'special-purpose-calendar-ical')
|
||||
{
|
||||
content = U('/api/calendar/ical?secret=' + apikey_key);
|
||||
}
|
||||
return getQRCodeForContent(content);
|
||||
}
|
||||
|
Reference in New Issue
Block a user