First commit
This commit is contained in:
94
application/demo/leftSide/leftSide.button.signout.js
Normal file
94
application/demo/leftSide/leftSide.button.signout.js
Normal file
@@ -0,0 +1,94 @@
|
||||
|
||||
|
||||
import menuButton from './leftSide.button.js';
|
||||
|
||||
import groups from '/user/group/user.group.permission.js';
|
||||
|
||||
import userManager from '/server/userManager.js';
|
||||
|
||||
|
||||
export default class signoutButton extends menuButton{
|
||||
|
||||
text = "Signout";
|
||||
|
||||
create(){
|
||||
|
||||
this.hide();
|
||||
|
||||
}
|
||||
|
||||
async click() {
|
||||
|
||||
this.stateMachine.composeState( "Signout" );
|
||||
|
||||
await this.openPage();
|
||||
|
||||
}
|
||||
|
||||
state async openPage() {
|
||||
|
||||
this.deactivateButtons();
|
||||
this.activateButton();
|
||||
|
||||
console.log("before process",this);
|
||||
|
||||
var visitorUser = await this.signout();
|
||||
|
||||
|
||||
localStorage.setItem( "username", false );
|
||||
|
||||
localStorage.setItem( "sessionKey", false );
|
||||
|
||||
this.getCore().updatePermissions( visitorUser.permissionObjects );
|
||||
|
||||
}
|
||||
|
||||
createVisitor( client ) {
|
||||
|
||||
var userInstance = new user();
|
||||
|
||||
userInstance.username.value = "Visitor";
|
||||
|
||||
userInstance.id = 0;
|
||||
|
||||
userInstance.permissionObjects = userManager.getPermissions( userInstance, client );
|
||||
|
||||
return userInstance;
|
||||
|
||||
}
|
||||
|
||||
node async signout( object, client ) {
|
||||
|
||||
var newUser = this.createVisitor( this.client );
|
||||
|
||||
this.client.user = newUser;
|
||||
|
||||
global.core.setUserObjects( false, this.client );
|
||||
|
||||
return newUser;
|
||||
|
||||
}
|
||||
|
||||
enableREAD() {
|
||||
|
||||
this.show();
|
||||
|
||||
}
|
||||
|
||||
disableREAD() {
|
||||
|
||||
this.hide();
|
||||
|
||||
}
|
||||
|
||||
permission() {
|
||||
|
||||
this.allow( groups.member , "PROCESS" );
|
||||
this.allow( groups.admin , "PROCESS" );
|
||||
|
||||
this.allow( groups.member , "READ" );
|
||||
this.allow( groups.admin , "READ" );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user