Skip to content

Commit

Permalink
Use 2FA description if name is not available #190
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Mar 5, 2022
1 parent 7474363 commit 8590e44
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 6 additions & 1 deletion app/import/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,12 @@ const qrConvert = (data) => {
url = url.slice(secret.length + 14 + 1)

// get issuer
const issuer = url
let issuer = url

// check if issuer is empty
if (issuer === "") {
issuer = name
}

// add to final string
return `\nName: ${name} \nSecret: ${secret} \nIssuer: ${issuer} \nType: OTP_TOTP\n`
Expand Down
6 changes: 3 additions & 3 deletions lib/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = {
const names_after = names_before.slice(8)

if (names_after.length > 40) {
names.push(`${names_after.trim().slice(0, 40)}...`)
names.push(`${names_after.trim().slice(0, 38)}...`)
} else {
names.push(names_after.trim())
}
Expand All @@ -67,8 +67,8 @@ module.exports = {
const issuers_before = data[i]
const issuers_after = issuers_before.slice(8)

if (issuers_after.length > 15) {
issuers.push(`${issuers_after.trim().slice(0, 15)}...`)
if (issuers_after.length > 16) {
issuers.push(`${issuers_after.trim().slice(0, 14)}...`)
} else {
issuers.push(issuers_after.trim())
}
Expand Down
4 changes: 4 additions & 0 deletions lib/qrcodeConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ module.exports = {
issuer: final.otp_parameters[i].issuer,
}

if (obj.issuer === "") {
obj.issuer = obj.name
}

arr.push(obj)
}

Expand Down

0 comments on commit 8590e44

Please sign in to comment.