From 2f495dfd62fecb9fe05f223f123b3bd4691132b8 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Mon, 21 Jun 2021 14:53:58 -0700 Subject: [PATCH] tag unpassworded users --- constants/globals.go | 5 +++++ lib.go | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 constants/globals.go diff --git a/constants/globals.go b/constants/globals.go new file mode 100644 index 0000000..88c80f3 --- /dev/null +++ b/constants/globals.go @@ -0,0 +1,5 @@ +package constants + +// We offer "un-passworded" profiles but our storage encrypts everything with a password. We need an agreed upon +// password to use in that case, that the app case use behind the scenes to password and unlock with +const DefactoPasswordForUnencryptedProfiles = "be gay do crime" diff --git a/lib.go b/lib.go index 1a1b657..f20cbf6 100644 --- a/lib.go +++ b/lib.go @@ -12,6 +12,7 @@ import ( "cwtch.im/cwtch/peer" "encoding/json" "fmt" + "git.openprivacy.ca/flutter/libcwtch-go/constants" contact "git.openprivacy.ca/flutter/libcwtch-go/features/contacts" "git.openprivacy.ca/flutter/libcwtch-go/features/groups" "git.openprivacy.ca/flutter/libcwtch-go/utils" @@ -91,7 +92,7 @@ func _startCwtch(appDir string, torPath string) { // Ensure that the application directory exists...and then initialize settings.. os.MkdirAll(path.Join(appDir), 0700) - utils.InitGlobalSettingsFile(appDir, "be gay do crime") + utils.InitGlobalSettingsFile(appDir, constants.DefactoPasswordForUnencryptedProfiles) log.Infof("Loading Cwtch Directory %v and tor path: %v", appDir, torPath) @@ -143,7 +144,7 @@ func _startCwtch(appDir string, torPath string) { settings := utils.ReadGlobalSettings() settingsJson, _ := json.Marshal(settings) - newApp.LoadProfiles("be gay do crime") + newApp.LoadProfiles(constants.DefactoPasswordForUnencryptedProfiles) application = newApp // Send global settings to the UI... @@ -351,7 +352,11 @@ func c_CreateProfile(nick_ptr *C.char, nick_len C.int, pass_ptr *C.char, pass_le } func CreateProfile(nick, pass string) { - application.CreatePeer(nick, pass) + if pass == constants.DefactoPasswordForUnencryptedProfiles { + application.CreateTaggedPeer(nick, pass, constants.ProfileTypeV1DefaultPassword) + } else { + application.CreateTaggedPeer(nick, pass, constants.ProfileTypeV1Password) + } } //export c_LoadProfiles