mirror of
https://github.com/mautrix/whatsapp.git
synced 2025-03-14 14:15:38 +00:00
legacyprovision: logout other logins when making new one
This commit is contained in:
parent
25f13a3ae4
commit
e7d0842f20
1 changed files with 10 additions and 0 deletions
|
@ -12,6 +12,7 @@ import (
|
|||
"go.mau.fi/util/exhttp"
|
||||
"go.mau.fi/whatsmeow/types"
|
||||
"maunium.net/go/mautrix"
|
||||
"maunium.net/go/mautrix/bridge/status"
|
||||
"maunium.net/go/mautrix/bridgev2"
|
||||
"maunium.net/go/mautrix/bridgev2/matrix"
|
||||
"maunium.net/go/mautrix/id"
|
||||
|
@ -189,10 +190,19 @@ func legacyProvLogin(w http.ResponseWriter, r *http.Request) {
|
|||
"platform": step.CompleteParams.UserLogin.Client.(*connector.WhatsAppClient).Device.Platform,
|
||||
"phone": step.CompleteParams.UserLogin.RemoteProfile.Phone,
|
||||
})
|
||||
go handleLoginComplete(context.WithoutCancel(ctx), user, step.CompleteParams.UserLogin)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
func handleLoginComplete(ctx context.Context, user *bridgev2.User, newLogin *bridgev2.UserLogin) {
|
||||
allLogins := user.GetUserLogins()
|
||||
for _, login := range allLogins {
|
||||
if login.ID != newLogin.ID {
|
||||
login.Delete(ctx, status.BridgeState{StateEvent: status.StateLoggedOut, Reason: "LOGIN_OVERRIDDEN"}, bridgev2.DeleteOpts{})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func legacyProvLogout(w http.ResponseWriter, r *http.Request) {
|
||||
user := m.Matrix.Provisioning.GetUser(r)
|
||||
|
|
Loading…
Add table
Reference in a new issue