Skip to content

Commit

Permalink
check if user exists
Browse files Browse the repository at this point in the history
  • Loading branch information
greenart7c3 committed Sep 16, 2023
1 parent 6696e55 commit 53110b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ object LocalPreferences {
updateCurrentAccount(npub)
}

fun containsAccount(npub: String): Boolean {
return savedAccounts().contains(npub)
}

/**
* Removes the account from the app level shared preferences
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class SignerProvider : ContentProvider() {
"content://com.greenart7c3.nostrsigner.SIGN_EVENT" -> {
val packageName = callingPackage ?: return null
val json = projection?.first() ?: return null
if (!LocalPreferences.containsAccount(projection[2])) return null
val account = LocalPreferences.loadFromEncryptedStorage() ?: return null
val event = Event.fromJson(json)
val key = "$packageName-SIGN_EVENT-${event.kind}"
Expand Down Expand Up @@ -118,6 +119,7 @@ class SignerProvider : ContentProvider() {
"content://com.greenart7c3.nostrsigner.NIP04_DECRYPT" -> {
val packageName = callingPackage ?: return null
val encryptedContent = projection?.first() ?: return null
if (!LocalPreferences.containsAccount(projection[2])) return null
val key = "$packageName-NIP04_DECRYPT"
val pubkey = projection[1]
val account = LocalPreferences.loadFromEncryptedStorage() ?: return null
Expand All @@ -140,6 +142,7 @@ class SignerProvider : ContentProvider() {
"content://com.greenart7c3.nostrsigner.NIP44_DECRYPT" -> {
val packageName = callingPackage ?: return null
val encryptedContent = projection?.first() ?: return null
if (!LocalPreferences.containsAccount(projection[2])) return null
val key = "$packageName-NIP44_DECRYPT"
val pubkey = projection[1]
val account = LocalPreferences.loadFromEncryptedStorage() ?: return null
Expand Down Expand Up @@ -171,6 +174,7 @@ class SignerProvider : ContentProvider() {
"content://com.greenart7c3.nostrsigner.NIP04_ENCRYPT" -> {
val packageName = callingPackage ?: return null
val decryptedContent = projection?.first() ?: return null
if (!LocalPreferences.containsAccount(projection[2])) return null
val key = "$packageName-NIP04_ENCRYPT"
val pubkey = projection[1]
val account = LocalPreferences.loadFromEncryptedStorage() ?: return null
Expand Down Expand Up @@ -201,6 +205,7 @@ class SignerProvider : ContentProvider() {
"content://com.greenart7c3.nostrsigner.NIP44_ENCRYPT" -> {
val packageName = callingPackage ?: return null
val decryptedContent = projection?.first() ?: return null
if (!LocalPreferences.containsAccount(projection[2])) return null
val key = "$packageName-NIP44_ENCRYPT"
val pubkey = projection[1]
val account = LocalPreferences.loadFromEncryptedStorage() ?: return null
Expand All @@ -226,6 +231,7 @@ class SignerProvider : ContentProvider() {
"content://com.greenart7c3.nostrsigner.DECRYPT_ZAP_EVENT" -> {
val packageName = callingPackage ?: return null
val encryptedContent = projection?.first() ?: return null
if (!LocalPreferences.containsAccount(projection[2])) return null
val key = "$packageName-DECRYPT_ZAP_EVENT"
val account = LocalPreferences.loadFromEncryptedStorage() ?: return null
val isRemembered = account.savedApps[key] ?: false
Expand Down

0 comments on commit 53110b0

Please sign in to comment.