mirror of
https://github.com/pierre42100/ComunicWeb
synced 2025-06-19 12:25:16 +00:00
Can sign out from all connected devices
This commit is contained in:
62
assets/js/pages/settings/sections/globalLogout.js
Normal file
62
assets/js/pages/settings/sections/globalLogout.js
Normal file
@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Global logout section
|
||||
*
|
||||
* In this section, the user can choose to sign out
|
||||
* from all its devices
|
||||
*
|
||||
* @author Pierre Hubert
|
||||
*/
|
||||
|
||||
const GlobalSignOutSection = {
|
||||
/**
|
||||
* Open settings section
|
||||
*
|
||||
* @param {object} args Additionnal arguments
|
||||
* @param {HTMLElement} target The target for the page
|
||||
*/
|
||||
open: function(args, target) {
|
||||
|
||||
//Create a box
|
||||
var box = createElem2({
|
||||
appendTo: target,
|
||||
type: "div",
|
||||
class: "box box-primary box-global-logout"
|
||||
});
|
||||
|
||||
//Add box header
|
||||
var boxHead = createElem2({
|
||||
appendTo: box,
|
||||
type: "div",
|
||||
class: "box-header",
|
||||
});
|
||||
var boxTitle = createElem2({
|
||||
appendTo: boxHead,
|
||||
type: "h3",
|
||||
class: "box-title",
|
||||
innerHTML: "Sign out from all devices"
|
||||
});
|
||||
|
||||
//Create box body
|
||||
var boxBody = createElem2({
|
||||
appendTo: box,
|
||||
type: "div",
|
||||
class: "box-body",
|
||||
innerHTML: "<p>You can decide do sign out from all your connected devices (including the current one). You should do this if one of the devices you use to access Comunic is stolen.</p>"
|
||||
});
|
||||
|
||||
const signoutButton = createElem2({
|
||||
appendTo: boxBody,
|
||||
type: "div",
|
||||
class: "btn btn-danger form-submit",
|
||||
innerHTML: "Sign out from all devices"
|
||||
})
|
||||
|
||||
signoutButton.addEventListener("click",async (e) => {
|
||||
|
||||
if(!await showConfirmDialog("Do you really want to get disconnected on all your devices?"))
|
||||
return;
|
||||
|
||||
await AccountInterface.disconnectAllDevices();
|
||||
})
|
||||
}
|
||||
}
|
@ -41,11 +41,14 @@ ComunicWeb.pages.settings.sections.security = {
|
||||
class: "box-body"
|
||||
});
|
||||
|
||||
//Append the form to query user password
|
||||
// Append the form to query user password
|
||||
this._append_form_prompt_user_password(boxBody);
|
||||
|
||||
//Offer the user to update its password too
|
||||
// Offer the user to update its password too
|
||||
ComunicWeb.pages.settings.sections.password.open(args, target);
|
||||
|
||||
// Offer the user to sign out from its account
|
||||
GlobalSignOutSection.open(args, target);
|
||||
},
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user