@@ -41,7 +41,11 @@ enum Phase {
4141}
4242
4343interface 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 ;
4549 onError ?: ( error : { error : string } ) => void ;
4650 rowClassName ?: string ;
4751 buttonClassName ?: string ;
@@ -87,9 +91,9 @@ export default class ChangePassword extends React.Component<IProps, IState> {
8791
8892 // if the server supports it then don't sign user out of all devices
8993 const serverSupportsControlOfDevicesLogout = await cli . doesServerSupportLogoutDevices ( ) ;
90- const logoutDevices = serverSupportsControlOfDevicesLogout ? false : undefined ;
94+ const userHasOtherDevices = ( await cli . getDevices ( ) ) . devices . length > 1 ;
9195
92- if ( ! serverSupportsControlOfDevicesLogout && this . props . confirm ) {
96+ if ( userHasOtherDevices && ! serverSupportsControlOfDevicesLogout && this . props . confirm ) {
9397 // warn about logging out all devices
9498 const { finished } = Modal . createTrackedDialog < [ boolean ] > ( 'Change Password' , '' , QuestionDialog , {
9599 title : _t ( "Warning!" ) ,
@@ -124,14 +128,15 @@ export default class ChangePassword extends React.Component<IProps, IState> {
124128 if ( ! confirmed ) return ;
125129 }
126130
127- this . changePassword ( cli , oldPassword , newPassword , logoutDevices ) ;
131+ this . changePassword ( cli , oldPassword , newPassword , serverSupportsControlOfDevicesLogout , userHasOtherDevices ) ;
128132 }
129133
130134 private changePassword (
131135 cli : MatrixClient ,
132136 oldPassword : string ,
133137 newPassword : string ,
134- logoutDevices : boolean | undefined ,
138+ serverSupportsControlOfDevicesLogout : boolean ,
139+ userHasOtherDevices : boolean ,
135140 ) : void {
136141 const authDict = {
137142 type : 'm.login.password' ,
@@ -149,19 +154,21 @@ export default class ChangePassword extends React.Component<IProps, IState> {
149154 phase : Phase . Uploading ,
150155 } ) ;
151156
157+ const logoutDevices = serverSupportsControlOfDevicesLogout ? false : undefined ;
158+
152159 // undefined or true mean all devices signed out
153- const didLogoutAllDevices = logoutDevices !== false ;
160+ const didLogoutOutOtherDevices = ! serverSupportsControlOfDevicesLogout && userHasOtherDevices ;
154161
155162 cli . setPassword ( authDict , newPassword , logoutDevices ) . then ( ( ) => {
156163 if ( this . props . shouldAskForEmail ) {
157164 return this . optionallySetEmail ( ) . then ( ( confirmed ) => {
158165 this . props . onFinished ( {
159166 didSetEmail : confirmed ,
160- didLogoutAllDevices ,
167+ didLogoutOutOtherDevices ,
161168 } ) ;
162169 } ) ;
163170 } else {
164- this . props . onFinished ( { didLogoutAllDevices } ) ;
171+ this . props . onFinished ( { didLogoutOutOtherDevices } ) ;
165172 }
166173 } , ( err ) => {
167174 this . props . onError ( err ) ;
0 commit comments