Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/i18n/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,5 +624,9 @@ export default {
After_seconds_set_by_admin: 'After {{seconds}} seconds (set by admin)',
Dont_activate: 'Don\'t activate now',
Queued_chats: 'Queued chats',
Queue_is_empty: 'Queue is empty'
Queue_is_empty: 'Queue is empty',
Logout_from_other_logged_in_locations: 'Logout from other logged in locations',
You_will_be_logged_out_from_all_locations: 'You\'ll be logged out from all locations.',
Successfully_logged_out: 'Successfully logged out!',
Logout_failed: 'Logout failed!'
};
6 changes: 5 additions & 1 deletion app/i18n/locales/pt-BR.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,5 +569,9 @@ export default {
After_seconds_set_by_admin: 'Após {{seconds}} segundos (Configurado pelo adm)',
Dont_activate: 'Não ativar agora',
Queued_chats: 'Bate-papos na fila',
Queue_is_empty: 'A fila está vazia'
Queue_is_empty: 'A fila está vazia',
Logout_from_other_logged_in_locations: 'Sair de outros locais logados',
You_will_be_logged_out_from_all_locations: 'Você sairá de todos os locais.',
Successfully_logged_out: 'Desconectado com sucesso!',
Logout_failed: 'Falha ao desconectar!'
};
4 changes: 4 additions & 0 deletions app/lib/rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,10 @@ const RocketChat = {
return user;
},
logout,
logoutOtherLocations() {
const { id: userId } = reduxStore.getState().login.user;
return this.methodCallWrapper('logoutOtherClients', { id: userId });
Comment thread
youssef-md marked this conversation as resolved.
Outdated
},
removeServer,
async clearCache({ server }) {
try {
Expand Down
2 changes: 2 additions & 0 deletions app/utils/log/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ export default {
PROFILE_SAVE_AVATAR_F: 'profile_save_avatar_f',
PROFILE_SAVE_CHANGES: 'profile_save_changes',
PROFILE_SAVE_CHANGES_F: 'profile_save_changes_f',
PROFILE_LOGOUT_OTHER_LOCATIONS: 'profile_logout_other_locations',
PROFILE_LOGOUT_OTHER_LOCATIONS_F: 'profile_logout_other_locations_f',

// SETTINGS VIEW
SE_CONTACT_US: 'se_contact_us',
Expand Down
26 changes: 25 additions & 1 deletion app/views/ProfileView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import KeyboardView from '../../presentation/KeyboardView';
import sharedStyles from '../Styles';
import styles from './styles';
import scrollPersistTaps from '../../utils/scrollPersistTaps';
import { showErrorAlert } from '../../utils/info';
import { showErrorAlert, showConfirmationAlert } from '../../utils/info';
import { LISTENER } from '../../containers/Toast';
import EventEmitter from '../../utils/events';
import RocketChat from '../../lib/rocketchat';
Expand Down Expand Up @@ -423,6 +423,23 @@ class ProfileView extends React.Component {
}
}

logoutOtherLocations = () => {
logEvent(events.PROFILE_LOGOUT_OTHER_LOCATIONS);
showConfirmationAlert({
message: I18n.t('You_will_be_logged_out_from_all_locations'),
callToAction: I18n.t('Logout'),
onPress: async() => {
try {
await RocketChat.logoutOtherLocations();
EventEmitter.emit(LISTENER, { message: I18n.t('Successfully_logged_out') });
} catch {
logEvent(events.PROFILE_LOGOUT_OTHER_LOCATIONS_F);
EventEmitter.emit(LISTENER, { message: I18n.t('Logout_failed') });
}
}
});
}

render() {
const {
name, username, email, newPassword, avatarUrl, customFields, avatar, saving
Expand Down Expand Up @@ -549,6 +566,13 @@ class ProfileView extends React.Component {
loading={saving}
theme={theme}
/>
<Button
title={I18n.t('Logout_from_other_logged_in_locations')}
type='secondary'
onPress={this.logoutOtherLocations}
testID='profile-view-logout-other-locations'
theme={theme}
/>
</ScrollView>
</SafeAreaView>
</KeyboardView>
Expand Down