Replace setNewPassword with updateAuthInfo in PopupUpdatePassword

This commit is contained in:
Benoit Martins 2025-07-10 15:16:59 +02:00
parent 37b913d692
commit 8ee693a092
2 changed files with 34 additions and 1 deletions

View file

@ -57,6 +57,8 @@ class CoreContext: ObservableObject {
private var callStateCallBacks: [((Call.State) -> Void)] = []
private var configuringStateCallBacks: [((ConfiguringState) -> Void)] = []
var digestAuthInfoPendingPasswordUpdate: AuthInfo?
private init() {
do {
try initialiseCore()
@ -284,6 +286,8 @@ class CoreContext: ObservableObject {
userInfo: ["address": "sip:" + identity]
)
}
self.digestAuthInfoPendingPasswordUpdate = authInfo
}
}, onTransferStateChanged: { (_: Core, transferred: Call, callState: Call.State) in
Log.info("[CoreContext] Transferred call \(transferred.remoteAddress!.asStringUriOnly()) state changed \(callState)")

View file

@ -79,6 +79,9 @@ struct PopupUpdatePassword: View {
.stroke(isPasswordFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1)
)
.padding(.bottom)
.onTapGesture {
isPasswordFocused = true
}
Button(action: {
isShowUpdatePasswordPopup = false
@ -99,7 +102,7 @@ struct PopupUpdatePassword: View {
.padding(.bottom, 10)
Button(action: {
setNewPassword()
updateAuthInfo()
isShowUpdatePasswordPopup = false
}, label: {
Text("dialog_ok")
@ -122,9 +125,11 @@ struct PopupUpdatePassword: View {
.shadow(color: Color.orangeMain500, radius: 0, x: 0, y: 2)
.frame(maxWidth: SharedMainViewModel.shared.maxWidth)
.position(x: geometry.size.width / 2, y: geometry.size.height / 2)
.onTapGesture {}
}
}
/*
func setNewPassword() {
CoreContext.shared.doOnCoreQueue { core in
Log.info("[SetNewPassword] ---- \(core.defaultAccount?.params?.identityAddress?.asStringUriOnly() ?? "No account found") \(passwordUpdateAddress)")
@ -146,6 +151,30 @@ struct PopupUpdatePassword: View {
}
}
}
*/
func updateAuthInfo() {
CoreContext.shared.doOnCoreQueue { core in
Log.info("[SetNewPassword] ---- \(core.defaultAccount?.params?.identityAddress?.asStringUriOnly() ?? "No account found") \(passwordUpdateAddress)")
if let account = core.accountList.first { $0.params?.identityAddress?.asStringUriOnly() == passwordUpdateAddress } {
let authInfo = CoreContext.shared.digestAuthInfoPendingPasswordUpdate
if (authInfo != nil) {
Log.info(
"[SetNewPassword] Updating password for username \(authInfo!.username) using auth info \(authInfo!)"
)
authInfo!.password = passwordPopupText
core.addAuthInfo(info: authInfo!)
CoreContext.shared.digestAuthInfoPendingPasswordUpdate = nil
core.refreshRegisters()
} else {
Log.warn(
"[SetNewPassword] Failed to find auth info for account \(account.params?.identityAddress?.asStringUriOnly())"
)
}
}
}
}
}
#Preview {