@@ -41,7 +41,11 @@ enum Phase {
41
41
}
42
42
43
43
interface IProps {
44
- onFinished ?: ( outcome : { didSetEmail ?: boolean , didLogoutAllDevices : boolean } ) => void ;
44
+ onFinished ?: ( outcome : {
45
+ didSetEmail ?: boolean ;
46
+ /** Was one or more other devices logged out whilst changing the password */
47
+ didLogoutOutOtherDevices : boolean ;
48
+ } ) => void ;
45
49
onError ?: ( error : { error : string } ) => void ;
46
50
rowClassName ?: string ;
47
51
buttonClassName ?: string ;
@@ -87,9 +91,9 @@ export default class ChangePassword extends React.Component<IProps, IState> {
87
91
88
92
// if the server supports it then don't sign user out of all devices
89
93
const serverSupportsControlOfDevicesLogout = await cli . doesServerSupportLogoutDevices ( ) ;
90
- const logoutDevices = serverSupportsControlOfDevicesLogout ? false : undefined ;
94
+ const userHasOtherDevices = ( await cli . getDevices ( ) ) . devices . length > 1 ;
91
95
92
- if ( ! serverSupportsControlOfDevicesLogout && this . props . confirm ) {
96
+ if ( userHasOtherDevices && ! serverSupportsControlOfDevicesLogout && this . props . confirm ) {
93
97
// warn about logging out all devices
94
98
const { finished } = Modal . createTrackedDialog < [ boolean ] > ( 'Change Password' , '' , QuestionDialog , {
95
99
title : _t ( "Warning!" ) ,
@@ -124,14 +128,15 @@ export default class ChangePassword extends React.Component<IProps, IState> {
124
128
if ( ! confirmed ) return ;
125
129
}
126
130
127
- this . changePassword ( cli , oldPassword , newPassword , logoutDevices ) ;
131
+ this . changePassword ( cli , oldPassword , newPassword , serverSupportsControlOfDevicesLogout , userHasOtherDevices ) ;
128
132
}
129
133
130
134
private changePassword (
131
135
cli : MatrixClient ,
132
136
oldPassword : string ,
133
137
newPassword : string ,
134
- logoutDevices : boolean | undefined ,
138
+ serverSupportsControlOfDevicesLogout : boolean ,
139
+ userHasOtherDevices : boolean ,
135
140
) : void {
136
141
const authDict = {
137
142
type : 'm.login.password' ,
@@ -149,19 +154,21 @@ export default class ChangePassword extends React.Component<IProps, IState> {
149
154
phase : Phase . Uploading ,
150
155
} ) ;
151
156
157
+ const logoutDevices = serverSupportsControlOfDevicesLogout ? false : undefined ;
158
+
152
159
// undefined or true mean all devices signed out
153
- const didLogoutAllDevices = logoutDevices !== false ;
160
+ const didLogoutOutOtherDevices = ! serverSupportsControlOfDevicesLogout && userHasOtherDevices ;
154
161
155
162
cli . setPassword ( authDict , newPassword , logoutDevices ) . then ( ( ) => {
156
163
if ( this . props . shouldAskForEmail ) {
157
164
return this . optionallySetEmail ( ) . then ( ( confirmed ) => {
158
165
this . props . onFinished ( {
159
166
didSetEmail : confirmed ,
160
- didLogoutAllDevices ,
167
+ didLogoutOutOtherDevices ,
161
168
} ) ;
162
169
} ) ;
163
170
} else {
164
- this . props . onFinished ( { didLogoutAllDevices } ) ;
171
+ this . props . onFinished ( { didLogoutOutOtherDevices } ) ;
165
172
}
166
173
} , ( err ) => {
167
174
this . props . onError ( err ) ;
0 commit comments