add privacy module
This commit is contained in:
parent
7c8f3f5923
commit
7be5572ede
|
@ -14,6 +14,7 @@ import ../../app_service/service/setting/service as setting_service
|
|||
import ../../app_service/service/bookmarks/service as bookmark_service
|
||||
import ../../app_service/service/dapp_permissions/service as dapp_permissions_service
|
||||
import ../../app_service/service/mnemonic/service as mnemonic_service
|
||||
import ../../app_service/service/privacy/service as privacy_service
|
||||
|
||||
import ../core/local_account_settings
|
||||
import ../../app_service/service/profile/service as profile_service
|
||||
|
@ -79,6 +80,7 @@ type
|
|||
aboutService: about_service.Service
|
||||
languageService: language_service.Service
|
||||
mnemonicService: mnemonic_service.Service
|
||||
privacyService: privacy_service.Service
|
||||
|
||||
# Core
|
||||
localAppSettingsVariant: QVariant
|
||||
|
@ -139,6 +141,7 @@ proc newAppController*(appService: AppService): AppController =
|
|||
result.dappPermissionsService = dapp_permissions_service.newService()
|
||||
result.languageService = language_service.newService()
|
||||
result.mnemonicService = mnemonic_service.newService()
|
||||
result.privacyService = privacy_service.newService()
|
||||
|
||||
# Core
|
||||
result.localAppSettingsVariant = newQVariant(singletonInstance.localAppSettings)
|
||||
|
@ -171,7 +174,8 @@ proc newAppController*(appService: AppService): AppController =
|
|||
result.aboutService,
|
||||
result.dappPermissionsService,
|
||||
result.languageService,
|
||||
result.mnemonicService
|
||||
result.mnemonicService,
|
||||
result.privacyService
|
||||
)
|
||||
|
||||
#################################################
|
||||
|
|
|
@ -28,6 +28,7 @@ import ../../../app_service/service/contacts/service as contacts_service
|
|||
import ../../../app_service/service/about/service as about_service
|
||||
import ../../../app_service/service/language/service as language_service
|
||||
import ../../../app_service/service/mnemonic/service as mnemonic_service
|
||||
import ../../../app_service/service/privacy/service as privacy_service
|
||||
|
||||
export io_interface
|
||||
|
||||
|
@ -73,7 +74,8 @@ proc newModule*[T](
|
|||
aboutService: about_service.ServiceInterface,
|
||||
dappPermissionsService: dapp_permissions_service.ServiceInterface,
|
||||
languageService: language_service.ServiceInterface,
|
||||
mnemonicService: mnemonic_service.ServiceInterface
|
||||
mnemonicService: mnemonic_service.ServiceInterface,
|
||||
privacyService: privacy_service.ServiceInterface
|
||||
): Module[T] =
|
||||
result = Module[T]()
|
||||
result.delegate = delegate
|
||||
|
@ -104,7 +106,7 @@ proc newModule*[T](
|
|||
)
|
||||
|
||||
result.browserSectionModule = browser_section_module.newModule(result, bookmarkService, settingsService, dappPermissionsService)
|
||||
result.profileSectionModule = profile_section_module.newModule(result, events, accountsService, settingsService, profileService, contactsService, aboutService, languageService, mnemonicService)
|
||||
result.profileSectionModule = profile_section_module.newModule(result, events, accountsService, settingsService, profileService, contactsService, aboutService, languageService, mnemonicService, privacyService)
|
||||
|
||||
method delete*[T](self: Module[T]) =
|
||||
self.chatSectionModule.delete
|
||||
|
|
|
@ -7,6 +7,7 @@ import ../../../../app_service/service/accounts/service as accounts_service
|
|||
import ../../../../app_service/service/settings/service as settings_service
|
||||
import ../../../../app_service/service/language/service as language_service
|
||||
import ../../../../app_service/service/mnemonic/service as mnemonic_service
|
||||
import ../../../../app_service/service/privacy/service as privacy_service
|
||||
|
||||
export controller_interface
|
||||
|
||||
|
@ -19,8 +20,9 @@ type
|
|||
accountsService: accounts_service.ServiceInterface
|
||||
languageService: language_service.ServiceInterface
|
||||
mnemonicService: mnemonic_service.ServiceInterface
|
||||
privacyService: privacy_service.ServiceInterface
|
||||
|
||||
proc newController*[T](delegate: T, accountsService: accounts_service.ServiceInterface, settingsService: settings_service.ServiceInterface, profileService: profile_service.ServiceInterface, languageService: language_service.ServiceInterface, mnemonicService: mnemonic_service.ServiceInterface): Controller[T] =
|
||||
proc newController*[T](delegate: T, accountsService: accounts_service.ServiceInterface, settingsService: settings_service.ServiceInterface, profileService: profile_service.ServiceInterface, languageService: language_service.ServiceInterface, mnemonicService: mnemonic_service.ServiceInterface, privacyService: privacy_service.ServiceInterface): Controller[T] =
|
||||
result = Controller[T]()
|
||||
result.delegate = delegate
|
||||
result.profileService = profileService
|
||||
|
@ -28,6 +30,7 @@ proc newController*[T](delegate: T, accountsService: accounts_service.ServiceInt
|
|||
result.accountsService = accountsService
|
||||
result.languageService = languageService
|
||||
result.mnemonicService = mnemonicService
|
||||
result.privacyService = privacyService
|
||||
|
||||
method delete*[T](self: Controller[T]) =
|
||||
discard
|
||||
|
|
|
@ -9,11 +9,13 @@ import ../../../../app_service/service/contacts/service as contacts_service
|
|||
import ../../../../app_service/service/about/service as about_service
|
||||
import ../../../../app_service/service/language/service as language_service
|
||||
import ../../../../app_service/service/mnemonic/service as mnemonic_service
|
||||
import ../../../../app_service/service/privacy/service as privacy_service
|
||||
|
||||
import ./profile/module as profile_module
|
||||
import ./contacts/module as contacts_module
|
||||
import ./language/module as language_module
|
||||
import ./mnemonic/module as mnemonic_module
|
||||
import ./privacy/module as privacy_module
|
||||
import ./about/module as about_module
|
||||
|
||||
import eventemitter
|
||||
|
@ -32,6 +34,7 @@ type
|
|||
languageModule: language_module.AccessInterface
|
||||
contactsModule: contacts_module.AccessInterface
|
||||
mnemonicModule: mnemonic_module.AccessInterface
|
||||
privacyModule: privacy_module.AccessInterface
|
||||
aboutModule: about_module.AccessInterface
|
||||
|
||||
proc newModule*[T](delegate: T,
|
||||
|
@ -42,20 +45,22 @@ proc newModule*[T](delegate: T,
|
|||
contactsService: contacts_service.ServiceInterface,
|
||||
aboutService: about_service.ServiceInterface,
|
||||
languageService: language_service.ServiceInterface,
|
||||
mnemonicService: mnemonic_service.ServiceInterface
|
||||
mnemonicService: mnemonic_service.ServiceInterface,
|
||||
privacyService: privacy_service.ServiceInterface
|
||||
):
|
||||
Module[T] =
|
||||
result = Module[T]()
|
||||
result.delegate = delegate
|
||||
result.view = view.newView()
|
||||
result.viewVariant = newQVariant(result.view)
|
||||
result.controller = controller.newController[Module[T]](result, accountsService, settingsService, profileService, languageService, mnemonicService)
|
||||
result.controller = controller.newController[Module[T]](result, accountsService, settingsService, profileService, languageService, mnemonicService, privacyService)
|
||||
result.moduleLoaded = false
|
||||
|
||||
result.profileModule = profile_module.newModule(result, accountsService, settingsService, profileService)
|
||||
result.contactsModule = contacts_module.newModule(result, events, contactsService, accountsService)
|
||||
result.languageModule = language_module.newModule(result, languageService)
|
||||
result.mnemonicModule = mnemonic_module.newModule(result, mnemonicService)
|
||||
result.privacyModule = privacy_module.newModule(result, privacyService, accountsService)
|
||||
result.aboutModule = about_module.newModule(result, aboutService)
|
||||
|
||||
singletonInstance.engine.setRootContextProperty("profileSectionModule", result.viewVariant)
|
||||
|
@ -65,6 +70,7 @@ method delete*[T](self: Module[T]) =
|
|||
self.contactsModule.delete
|
||||
self.languageModule.delete
|
||||
self.mnemonicModule.delete
|
||||
self.privacyModule.delete
|
||||
self.aboutModule.delete
|
||||
|
||||
self.view.delete
|
||||
|
@ -76,6 +82,7 @@ method load*[T](self: Module[T]) =
|
|||
self.contactsModule.load()
|
||||
self.languageModule.load()
|
||||
self.mnemonicModule.load()
|
||||
self.privacyModule.load()
|
||||
self.aboutModule.load()
|
||||
|
||||
self.moduleLoaded = true
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
import ./controller_interface
|
||||
import ../../../../../app_service/service/accounts/service as accounts_service
|
||||
import ../../../../../app_service/service/privacy/service as privacy_service
|
||||
|
||||
export controller_interface
|
||||
|
||||
type
|
||||
Controller*[T: controller_interface.DelegateInterface] = ref object of controller_interface.AccessInterface
|
||||
delegate: T
|
||||
accountsService: accounts_service.ServiceInterface
|
||||
privacyService: privacy_service.ServiceInterface
|
||||
|
||||
proc newController*[T](delegate: T, privacyService: privacy_service.ServiceInterface, accountsService: accounts_service.ServiceInterface): Controller[T] =
|
||||
result = Controller[T]()
|
||||
result.delegate = delegate
|
||||
result.accountsService = accountsService
|
||||
result.privacyService = privacyService
|
||||
|
||||
method delete*[T](self: Controller[T]) =
|
||||
discard
|
||||
|
||||
method init*[T](self: Controller[T]) =
|
||||
discard
|
||||
|
||||
method getLinkPreviewWhitelist*[T](self: Controller[T]): string =
|
||||
return self.privacyService.getLinkPreviewWhitelist()
|
||||
|
||||
method changePassword*[T](self: Controller[T], password: string, newPassword: string): bool =
|
||||
let loggedInAccount = self.accountsService.getLoggedInAccount()
|
||||
return self.privacyService.changePassword(loggedInAccount.keyUid, password, newPassword)
|
|
@ -0,0 +1,22 @@
|
|||
# import ../../../../../app_service/service/profile/service as profile_service
|
||||
|
||||
type
|
||||
AccessInterface* {.pure inheritable.} = ref object of RootObj
|
||||
## Abstract class for any input/interaction with this module.
|
||||
|
||||
method delete*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method init*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getLinkPreviewWhitelist*(self: AccessInterface): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method changePassword*(self: AccessInterface, password: string, newPassword: string): bool {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
type
|
||||
## Abstract class (concept) which must be implemented by object/s used in this
|
||||
## module.
|
||||
DelegateInterface* = concept c
|
|
@ -0,0 +1,23 @@
|
|||
type
|
||||
AccessInterface* {.pure inheritable.} = ref object of RootObj
|
||||
## Abstract class for any input/interaction with this module.
|
||||
|
||||
method delete*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method load*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method isLoaded*(self: AccessInterface): bool {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getLinkPreviewWhitelist*(self: AccessInterface): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method changePassword*(self: AccessInterface, password: string, newPassword: string): bool {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
type
|
||||
## Abstract class (concept) which must be implemented by object/s used in this
|
||||
## module.
|
||||
DelegateInterface* = concept c
|
|
@ -0,0 +1,42 @@
|
|||
import NimQml, Tables
|
||||
|
||||
import ./io_interface, ./view, ./controller
|
||||
import ../../../../core/global_singleton
|
||||
|
||||
import ../../../../../app_service/service/accounts/service as accounts_service
|
||||
import ../../../../../app_service/service/privacy/service as privacy_service
|
||||
|
||||
export io_interface
|
||||
|
||||
type
|
||||
Module* [T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface
|
||||
delegate: T
|
||||
controller: controller.AccessInterface
|
||||
view: View
|
||||
viewVariant: QVariant
|
||||
moduleLoaded: bool
|
||||
|
||||
proc newModule*[T](delegate: T, privacyService: privacy_service.ServiceInterface, accountsService: accounts_service.ServiceInterface): Module[T] =
|
||||
result = Module[T]()
|
||||
result.delegate = delegate
|
||||
result.view = newView(result)
|
||||
result.viewVariant = newQVariant(result.view)
|
||||
result.controller = controller.newController[Module[T]](result, privacyService, accountsService)
|
||||
result.moduleLoaded = false
|
||||
|
||||
singletonInstance.engine.setRootContextProperty("privacyModule", result.viewVariant)
|
||||
|
||||
method delete*[T](self: Module[T]) =
|
||||
self.view.delete
|
||||
|
||||
method load*[T](self: Module[T]) =
|
||||
self.moduleLoaded = true
|
||||
|
||||
method isLoaded*[T](self: Module[T]): bool =
|
||||
return self.moduleLoaded
|
||||
|
||||
method getLinkPreviewWhitelist*[T](self: Module[T]): string =
|
||||
return self.controller.getLinkPreviewWhitelist()
|
||||
|
||||
method changePassword*[T](self: Module[T], password: string, newPassword: string): bool =
|
||||
return self.controller.changePassword(password, newPassword)
|
|
@ -0,0 +1,23 @@
|
|||
import NimQml
|
||||
|
||||
# import ./controller_interface
|
||||
import ./io_interface
|
||||
|
||||
QtObject:
|
||||
type
|
||||
View* = ref object of QObject
|
||||
delegate: io_interface.AccessInterface
|
||||
|
||||
proc delete*(self: View) =
|
||||
self.QObject.delete
|
||||
|
||||
proc newView*(delegate: io_interface.AccessInterface): View =
|
||||
new(result, delete)
|
||||
result.QObject.setup
|
||||
result.delegate = delegate
|
||||
|
||||
proc getLinkPreviewWhitelist*(self: View): string {.slot.} =
|
||||
return self.delegate.getLinkPreviewWhitelist()
|
||||
|
||||
proc changePassword*(self: View, password: string, newPassword: string): bool {.slot.} =
|
||||
return self.delegate.changePassword(password, newPassword)
|
|
@ -0,0 +1,52 @@
|
|||
import json, json_serialization, sequtils, chronicles
|
||||
import status/statusgo_backend/eth as eth
|
||||
import status/statusgo_backend/settings as status_go_settings
|
||||
import status/statusgo_backend/accounts as status_go_accounts
|
||||
|
||||
import ../../../constants
|
||||
|
||||
import ./service_interface, ./dto
|
||||
|
||||
export service_interface
|
||||
|
||||
logScope:
|
||||
topics = "privacy-service"
|
||||
|
||||
type
|
||||
Service* = ref object of ServiceInterface
|
||||
# profile: Dto
|
||||
|
||||
method delete*(self: Service) =
|
||||
discard
|
||||
|
||||
proc newService*(): Service =
|
||||
result = Service()
|
||||
|
||||
method init*(self: Service) =
|
||||
try:
|
||||
echo "init"
|
||||
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "error: ", errDesription
|
||||
return
|
||||
|
||||
method getLinkPreviewWhitelist*(self: Service): string =
|
||||
return $(status_go_settings.getLinkPreviewWhitelist())
|
||||
|
||||
method changePassword*(self: Service, address: string, password: string, newPassword: string): bool =
|
||||
let
|
||||
defaultAccount = eth.getDefaultAccount()
|
||||
isPasswordOk = status_go_accounts.verifyAccountPassword(defaultAccount, password, KEYSTOREDIR)
|
||||
if not isPasswordOk:
|
||||
return false
|
||||
|
||||
return changeDatabasePassword(address, password, newPassword)
|
||||
|
||||
proc changeDatabasePassword(keyUID: string, password: string, newPassword: string): bool =
|
||||
try:
|
||||
if not status_go_accounts.changeDatabasePassword(keyUID, password, newPassword):
|
||||
return false
|
||||
except:
|
||||
return false
|
||||
return true
|
|
@ -0,0 +1,19 @@
|
|||
import dto
|
||||
|
||||
export dto
|
||||
|
||||
type
|
||||
ServiceInterface* {.pure inheritable.} = ref object of RootObj
|
||||
## Abstract class for this service access.
|
||||
|
||||
method delete*(self: ServiceInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method init*(self: ServiceInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method getLinkPreviewWhitelist*(self: ServiceInterface): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method changePassword*(self: ServiceInterface, address: string, password: string, newPassword: string): bool {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
|
@ -132,7 +132,7 @@ StatusModal {
|
|||
}
|
||||
|
||||
function changePasswordBegin() {
|
||||
if (profileModel.changePassword(currentPasswordInput.text, passwordInput.text)) {
|
||||
if (privacyModule.changePassword(currentPasswordInput.text, passwordInput.text)) {
|
||||
popup.successPopup.open();
|
||||
submitBtn.enabled = false;
|
||||
} else {
|
||||
|
|
|
@ -22,7 +22,7 @@ ModalPopup {
|
|||
}
|
||||
|
||||
function populatePreviewableSites() {
|
||||
let whitelist = JSON.parse(profileModel.getLinkPreviewWhitelist())
|
||||
let whitelist = JSON.parse(privacyModule.getLinkPreviewWhitelist())
|
||||
whitelist.forEach(entry => {
|
||||
entry.isWhitelisted = localAccountSensitiveSettings.whitelistedUnfurlingSites[entry.address] || false
|
||||
previewableSites.append(entry)
|
||||
|
|
Loading…
Reference in New Issue