change password
the build failed
Details
the build failed
Details
This commit is contained in:
parent
d77851a835
commit
13239c094c
|
@ -1,8 +1,10 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
"cwtch.im/cwtch/app"
|
||||
"cwtch.im/cwtch/event"
|
||||
"cwtch.im/cwtch/protocol/connections"
|
||||
"cwtch.im/ui/go/constants"
|
||||
"cwtch.im/ui/go/the"
|
||||
"cwtch.im/ui/go/ui"
|
||||
"git.openprivacy.ca/openprivacy/libricochet-go/log"
|
||||
|
@ -25,6 +27,8 @@ func PeerHandler(onion string, uiManager ui.Manager, subscribed chan bool) {
|
|||
eventBus.Subscribe(event.PeerStateChange, q)
|
||||
eventBus.Subscribe(event.PeerCreated, q)
|
||||
eventBus.Subscribe(event.NetworkStatus, q)
|
||||
eventBus.Subscribe(event.ChangePasswordSuccess, q)
|
||||
eventBus.Subscribe(event.ChangePasswordError, q)
|
||||
|
||||
subscribed <- true
|
||||
|
||||
|
@ -111,6 +115,13 @@ func PeerHandler(onion string, uiManager ui.Manager, subscribed chan bool) {
|
|||
log.Infof("PeerHandler got DeletePeer, SHUTTING down!\n")
|
||||
uiManager.ReloadProfiles()
|
||||
return
|
||||
case event.ChangePasswordSuccess:
|
||||
log.Infoln("ChangePAsswordSuccess!!!")
|
||||
peer.SetAttribute(app.AttributeTag, constants.ProfileTypeV1Password)
|
||||
uiManager.ChangePasswordResponse(false)
|
||||
case event.ChangePasswordError:
|
||||
uiManager.ChangePasswordResponse(true)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
29
go/ui/gcd.go
29
go/ui/gcd.go
|
@ -1,6 +1,7 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"cwtch.im/cwtch/app"
|
||||
"cwtch.im/cwtch/event"
|
||||
"cwtch.im/cwtch/protocol/connections"
|
||||
"cwtch.im/ui/go/constants"
|
||||
|
@ -42,6 +43,7 @@ type GrandCentralDispatcher struct {
|
|||
_ func() `signal:"ErrorLoaded0"`
|
||||
_ func() `signal:"ResetProfile"`
|
||||
_ func() `signal:"ResetProfileList"`
|
||||
_ func(failed bool) `signal:"ChangePasswordResponse"`
|
||||
|
||||
// contact list stuff
|
||||
_ func(handle, displayName, image, server string, badge, status int, blocked bool, loading bool, lastMsgTime int) `signal:"AddContact"`
|
||||
|
@ -77,12 +79,13 @@ type GrandCentralDispatcher struct {
|
|||
_ func() `signal:"onActivate,auto"`
|
||||
_ func(locale string) `signal:"setLocale,auto"`
|
||||
// profile managemenet
|
||||
_ func(onion, nick string) `signal:"updateNick,auto"`
|
||||
_ func(handle string) `signal:"loadProfile,auto"`
|
||||
_ func(nick string, defaultPass bool, password string) `signal:"createProfile,auto"`
|
||||
_ func(password string) `signal:"unlockProfiles,auto"`
|
||||
_ func() `signal:"reloadProfileList,auto"`
|
||||
_ func(onion string) `signal:"deleteProfile,auto"`
|
||||
_ func(onion, nick string) `signal:"updateNick,auto"`
|
||||
_ func(handle string) `signal:"loadProfile,auto"`
|
||||
_ func(nick string, defaultPass bool, password string) `signal:"createProfile,auto"`
|
||||
_ func(password string) `signal:"unlockProfiles,auto"`
|
||||
_ func() `signal:"reloadProfileList,auto"`
|
||||
_ func(onion string) `signal:"deleteProfile,auto"`
|
||||
_ func(onion, currentPassword, newPassword string, defaultPass bool) `signal:"changePassword,auto""`
|
||||
// operating a profile
|
||||
_ func(message string, mid string) `signal:"sendMessage,auto"`
|
||||
_ func(onion string) `signal:"blockPeer,auto"`
|
||||
|
@ -627,6 +630,20 @@ func (this *GrandCentralDispatcher) createProfile(nick string, defaultPass bool,
|
|||
}
|
||||
}
|
||||
|
||||
func (this *GrandCentralDispatcher) changePassword(onion, currentPassword, newPassword string, defaultPass bool) {
|
||||
tag, _ := the.CwtchApp.GetPeer(onion).GetAttribute(app.AttributeTag)
|
||||
|
||||
if tag == constants.ProfileTypeV1DefaultPassword {
|
||||
currentPassword = the.AppPassword
|
||||
}
|
||||
|
||||
if defaultPass {
|
||||
newPassword = the.AppPassword
|
||||
}
|
||||
|
||||
the.CwtchApp.ChangePeerPassword(onion, currentPassword, newPassword)
|
||||
}
|
||||
|
||||
func (this *GrandCentralDispatcher) reloadProfileList() {
|
||||
this.ResetProfileList()
|
||||
|
||||
|
|
|
@ -151,6 +151,8 @@ type Manager interface {
|
|||
UpdateContactDisplayName(handle string, name string)
|
||||
UpdateContactStatus(handle string, status int, loading bool)
|
||||
UpdateContactAttribute(handle, key, value string)
|
||||
|
||||
ChangePasswordResponse(error bool)
|
||||
}
|
||||
|
||||
// NewManager returns a new Manager interface for a profile to the gcd
|
||||
|
@ -273,3 +275,7 @@ func (this *manager) UpdateContactAttribute(handle, key, value string) {
|
|||
this.gcd.UpdateContactAttribute(handle, key, value)
|
||||
})
|
||||
}
|
||||
|
||||
func (this *manager) ChangePasswordResponse(error bool) {
|
||||
this.gcd.ChangePasswordResponse(error)
|
||||
}
|
||||
|
|
|
@ -14,6 +14,10 @@ ColumnLayout { // Add Profile Pane
|
|||
anchors.fill: parent
|
||||
|
||||
property string mode // edit or add
|
||||
property string onion
|
||||
property string tag
|
||||
property bool deleting
|
||||
property bool changingPassword
|
||||
|
||||
Widgets.StackToolbar {
|
||||
id: stb
|
||||
|
@ -24,30 +28,37 @@ ColumnLayout { // Add Profile Pane
|
|||
}
|
||||
|
||||
function reset() {
|
||||
mode = "add"
|
||||
txtProfileName.text = qsTr("default-profile-name")
|
||||
changingPassword = false
|
||||
txtPassword1.text = ""
|
||||
txtPassword2.text = ""
|
||||
deleteReset()
|
||||
deleting = false
|
||||
deleteConfirmLabel.color = "black"
|
||||
tag = ""
|
||||
confirmDeleteTxt.text = ""
|
||||
radioUsePassword.checked = true
|
||||
passwordChangeErrorLabel.visible = false
|
||||
}
|
||||
|
||||
function load(onion, name, pass) {
|
||||
function load(userOnion, name, userTag) {
|
||||
reset()
|
||||
|
||||
mode = "edit"
|
||||
tag = userTag
|
||||
onion = userOnion
|
||||
txtPassword1.text = ""
|
||||
txtPassword2.text = ""
|
||||
onionLabel.text = onion
|
||||
txtProfileName.text = name
|
||||
txtPassword1.text = pass
|
||||
txtPassword2.text = pass
|
||||
|
||||
deleteReset()
|
||||
if (tag == "v1-defaultPassword" || tag == "v1-default-password") {
|
||||
radioNoPassword.checked = true
|
||||
} else {
|
||||
radioUsePassword.checked = true
|
||||
}
|
||||
}
|
||||
|
||||
function deleteReset() {
|
||||
deleteConfirmLabel.visible = false
|
||||
deleteConfirmLabel.visible = false
|
||||
deleteConfirmLabel.color = "black"
|
||||
confirmDeleteTxt.visible = false
|
||||
confirmDeleteTxt.text = ""
|
||||
confirmDeleteBtn.visible = false
|
||||
}
|
||||
|
||||
Flickable {
|
||||
anchors.top: stb.bottom
|
||||
|
@ -99,12 +110,20 @@ ColumnLayout { // Add Profile Pane
|
|||
checked: true
|
||||
//: Password
|
||||
text: qsTr("radio-use-password")
|
||||
visible: mode == "add" || tag == "v1-defaultPassword"
|
||||
onClicked: {
|
||||
changingPassword = true
|
||||
}
|
||||
}
|
||||
|
||||
Widgets.RadioButton {
|
||||
id: radioNoPassword
|
||||
//: Unencrypted (No password)
|
||||
text: qsTr("radio-no-password")
|
||||
visible: mode == "add" || tag == "v1-defaultPassword"
|
||||
onClicked: {
|
||||
changingPassword = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,6 +134,20 @@ ColumnLayout { // Add Profile Pane
|
|||
visible: radioNoPassword.checked
|
||||
}
|
||||
|
||||
Widgets.ScalingLabel {
|
||||
id: currentPasswordLabel
|
||||
//: Current Password
|
||||
text: qsTr("current-password-label") + ":"
|
||||
visible: radioUsePassword.checked && mode == "edit" && tag != "v1-defaultPassword"
|
||||
}
|
||||
|
||||
Widgets.TextField {
|
||||
id: txtCurrentPassword
|
||||
Layout.fillWidth: true
|
||||
echoMode: TextInput.Password
|
||||
visible: radioUsePassword.checked && mode == "edit" && tag != "v1-defaultPassword"
|
||||
}
|
||||
|
||||
Widgets.ScalingLabel {
|
||||
id: passwordLabel
|
||||
//: Password
|
||||
|
@ -127,8 +160,11 @@ ColumnLayout { // Add Profile Pane
|
|||
Layout.fillWidth: true
|
||||
//style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
|
||||
echoMode: TextInput.Password
|
||||
readOnly: mode == "edit"
|
||||
visible: radioUsePassword.checked
|
||||
|
||||
onTextEdited: {
|
||||
changingPassword = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -144,28 +180,36 @@ ColumnLayout { // Add Profile Pane
|
|||
Layout.fillWidth: true
|
||||
//style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
|
||||
echoMode: TextInput.Password
|
||||
readOnly: mode == "edit"
|
||||
visible: radioUsePassword.checked
|
||||
}
|
||||
|
||||
Widgets.SimpleButton {
|
||||
Widgets.SimpleButton { // ADD or SAVE button
|
||||
//: Create Profile || Save Profile
|
||||
text: mode == "add" ? qsTr("create-profile-btn") : qsTr("save-profile-btn")
|
||||
|
||||
onClicked: {
|
||||
if (txtPassword1.text != txtPassword2.text) {
|
||||
passwordErrorLabel.visible = true
|
||||
if (mode == "add") {
|
||||
if (txtPassword1.text != txtPassword2.text) {
|
||||
passwordErrorLabel.visible = true
|
||||
} else {
|
||||
gcd.createProfile(txtProfileName.text, radioNoPassword.checked, txtPassword1.text)
|
||||
}
|
||||
} else {
|
||||
if (mode == "add") {
|
||||
gcd.createProfile(txtProfileName.text, radioNoPassword .checked, txtPassword1.text)
|
||||
} else {
|
||||
gcd.updateNick(onionLabel.text, txtProfileName.text)
|
||||
gcd.updateNick(onion, txtProfileName.text)
|
||||
|
||||
if (changingPassword) {
|
||||
if (txtPassword1.text != txtPassword2.text) {
|
||||
passwordErrorLabel.visible = true
|
||||
} else {
|
||||
gcd.changePassword(onion, txtCurrentPassword.text, txtPassword1.text, radioNoPassword.checked)
|
||||
return
|
||||
}
|
||||
}
|
||||
gcd.reloadProfileList()
|
||||
parentStack.pane = parentStack.managementPane
|
||||
}
|
||||
gcd.reloadProfileList()
|
||||
parentStack.pane = parentStack.managementPane
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Widgets.ScalingLabel {
|
||||
id: passwordErrorLabel
|
||||
|
@ -175,6 +219,16 @@ ColumnLayout { // Add Profile Pane
|
|||
color: "red"
|
||||
}
|
||||
|
||||
Widgets.ScalingLabel {
|
||||
id: passwordChangeErrorLabel
|
||||
//: Error changing password: Supplied password rejected
|
||||
text: qsTr("password-change-error")
|
||||
visible: false
|
||||
color: "red"
|
||||
}
|
||||
|
||||
// ***** Delete button and confirm flow *****
|
||||
|
||||
Widgets.SimpleButton {
|
||||
//: Delete Profile
|
||||
text: qsTr("delete-profile-btn")
|
||||
|
@ -183,10 +237,7 @@ ColumnLayout { // Add Profile Pane
|
|||
|
||||
|
||||
onClicked: {
|
||||
deleteConfirmLabel.visible = true
|
||||
deleteConfirmLabel.visible = true
|
||||
confirmDeleteTxt.visible = true
|
||||
confirmDeleteBtn.visible = true
|
||||
deleting = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,14 +245,14 @@ ColumnLayout { // Add Profile Pane
|
|||
id: deleteConfirmLabel
|
||||
//: Type DELETE to confirm
|
||||
text: qsTr("delete-confirm-label")+ ":"
|
||||
visible: false
|
||||
visible: deleting
|
||||
}
|
||||
|
||||
Widgets.TextField {
|
||||
id: confirmDeleteTxt
|
||||
Layout.fillWidth: true
|
||||
//style: CwtchTextFieldStyle{ width: tehcol.width * 0.8 }
|
||||
visible: false
|
||||
visible: deleting
|
||||
}
|
||||
|
||||
Widgets.SimpleButton {
|
||||
|
@ -211,12 +262,13 @@ ColumnLayout { // Add Profile Pane
|
|||
//: Really Delete Profile
|
||||
text: qsTr("delete-profile-confirm-btn")
|
||||
color: "red"
|
||||
visible: false
|
||||
visible: deleting
|
||||
|
||||
onClicked: {
|
||||
//: DELETE
|
||||
if (confirmDeleteTxt.text == qsTr("delete-confirm-text")) {
|
||||
gcd.deleteProfile(onionLabel.text)
|
||||
deleteConfirmLabel.color = "black"
|
||||
gcd.deleteProfile(onion)
|
||||
gcd.reloadProfileList()
|
||||
parentStack.pane = parentStack.managementPane
|
||||
} else {
|
||||
|
@ -229,4 +281,17 @@ ColumnLayout { // Add Profile Pane
|
|||
|
||||
}//end of column with padding
|
||||
}//end of flickable
|
||||
|
||||
Connections { // UPDATE UNREAD MESSAGES COUNTER
|
||||
target: gcd
|
||||
|
||||
onChangePasswordResponse: function(error) {
|
||||
if (!error) {
|
||||
gcd.reloadProfileList()
|
||||
parentStack.pane = parentStack.managementPane
|
||||
} else {
|
||||
passwordChangeErrorLabel.visible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -31,6 +31,7 @@ ColumnLayout {
|
|||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
style: CwtchTextFieldStyle{ width: thecol.width * 0.8 }
|
||||
echoMode: TextInput.Password
|
||||
onAccepted: button.clicked()
|
||||
}
|
||||
|
||||
Widgets.ScalingLabel {
|
||||
|
|
|
@ -183,7 +183,6 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
|
|||
gcd.loadProfile(handle)
|
||||
parentStack.pane = parentStack.profilePane
|
||||
} else if (type == "button") { // Add profile button
|
||||
profileAddEditPane.mode = "add"
|
||||
profileAddEditPane.reset()
|
||||
parentStack.pane = parentStack.addEditProfilePane
|
||||
}
|
||||
|
@ -214,8 +213,7 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
|
|||
|
||||
|
||||
onClicked: {
|
||||
profileAddEditPane.mode = "edit"
|
||||
profileAddEditPane.load(handle, displayName, "")
|
||||
profileAddEditPane.load(handle, displayName, tag)
|
||||
parentStack.pane = parentStack.addEditProfilePane
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue