mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Can sign out from all connected devices
This commit is contained in:
parent
f3b7091332
commit
a7a33bbdb8
11
assets/css/pages/settings/sections/globalLogout.css
Normal file
11
assets/css/pages/settings/sections/globalLogout.css
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Global logout section
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
.box-global-logout .form-submit {
|
||||
width: 170px;
|
||||
margin: auto;
|
||||
display: block;
|
||||
}
|
@ -291,3 +291,16 @@ function getGroups(list, force){
|
||||
function timeDiffToStr(time) {
|
||||
return ComunicWeb.common.date.timeDiffToStr(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask a confirmation to the user
|
||||
*
|
||||
* @param {String} msg Associated message
|
||||
*/
|
||||
async function showConfirmDialog(msg) {
|
||||
return new Promise((res, err) => {
|
||||
ComunicWeb.common.messages.confirm(msg, (c) => {
|
||||
res(c == true);
|
||||
});
|
||||
})
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
ComunicWeb.components.account.interface = {
|
||||
const AccountInterface = {
|
||||
|
||||
/**
|
||||
* Send a request on the server to create an account
|
||||
@ -134,6 +134,13 @@ ComunicWeb.components.account.interface = {
|
||||
ComunicWeb.common.api.makeAPIrequest(apiURI, params, false, callback);
|
||||
},
|
||||
|
||||
/**
|
||||
* Disconnect user from all its connected devices
|
||||
*/
|
||||
disconnectAllDevices: async function() {
|
||||
await api("/account/disconnect_all_devices", {}, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Request the export of all the data of the user
|
||||
*
|
||||
@ -163,3 +170,5 @@ ComunicWeb.components.account.interface = {
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
ComunicWeb.components.account.interface = AccountInterface;
|
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);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -274,6 +274,7 @@ class Dev {
|
||||
"css/pages/settings/sections/customEmojis.css",
|
||||
"css/pages/settings/sections/security.css",
|
||||
"css/pages/settings/sections/password.css",
|
||||
"css/pages/settings/sections/globalLogout.css",
|
||||
"css/pages/settings/sections/accountImage.css",
|
||||
"css/pages/settings/sections/privacy.css",
|
||||
|
||||
@ -533,6 +534,7 @@ class Dev {
|
||||
"js/pages/settings/sections/emojis.js",
|
||||
"js/pages/settings/sections/security.js",
|
||||
"js/pages/settings/sections/password.js",
|
||||
"js/pages/settings/sections/globalLogout.js",
|
||||
"js/pages/settings/sections/accountImage.js",
|
||||
"js/pages/settings/sections/privacy.js",
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user