Added page for forbbiden access to signed out users.

This commit is contained in:
Pierre 2017-12-17 18:48:02 +01:00
parent 4cc00b7868
commit ad6d3ed706
6 changed files with 152 additions and 17 deletions

View File

@ -0,0 +1,14 @@
/**
* Access To Page Forbidden stylesheet
*
* @author Pierre HUBERT
*/
/**
* Callout special stylesheet
*/
.user_page_access_forbidden {
margin: auto;
margin-top: 30px;
max-width: 500px;
}

View File

@ -390,6 +390,11 @@ var ComunicWeb = {
*/
getNames: function(usersID, afterNames){},
/**
* Get advanced informations about a user
*/
getAdvancedInfos: function(userID, callback){},
/**
* Get the user ID specified by its folder name
*/
@ -667,8 +672,25 @@ var ComunicWeb = {
*/
openUserPage: function(id, params, target){},
/**
* Display a user page
*/
displayUserPage: function(infos, params, target){},
},
/**
* Page with access forbidden
*/
accessForbidden: {
/**
* Display the page for user with forbidden access
*/
display: function(id, params, target){}
}
},
/**

View File

@ -0,0 +1,38 @@
/**
* Display informations about pages we are not allowed to show
*
* Handles request
*
* @author Pierre HUBERT
*/
ComunicWeb.pages.userPage.accessForbidden = {
/**
* Display the page for user with forbidden access
*
* @param {Integer} userID The ID of the target user
* @param {Object} params Additional parametres
* @param {HTMLElement} target The target element on the screen
*/
display: function(id, params, target){
//Check if user is signed in or not
if(!signed_in()){
//Inform user that he must sign in to continue
elem = ComunicWeb.common.messages.createCalloutElem(
"Sign in required",
"Please sign in to get access to this page.",
"danger"
);
elem.className += " user_page_access_forbidden";
target.appendChild(elem);
}
},
}

View File

@ -83,7 +83,44 @@ ComunicWeb.pages.userPage.main = {
//Log action
log("Open user page : " + id);
//Fetch informations about the user
ComunicWeb.user.userInfos.getAdvancedInfos(id, function(response){
//Check for errors
if(response.error){
//Check if the page was not found
if(response.error.code == 404){
ComunicWeb.common.error.pageNotFound(params, target);
}
//Check if we are not allowed to get the informations
if(response.error.code == 401){
//Display access forbidden page
ComunicWeb.pages.userPage.accessForbidden.display(id, params, target);
}
}
else {
//Display user page
ComunicWeb.pages.userPage.main.displayUserPage(response, params, target);
}
});
},
/**
* Display a user page
*
* @param {Object} infos Informations about the user to display
* @param {Object} params Parametres required to open the page
* @param {HTMLElement} target Target of the user page
*/
displayUserPage: function(infos, params, target){
console.log("Display user page based on the informations we got");
console.log(infos);
}
}

View File

@ -201,6 +201,25 @@ ComunicWeb.user.userInfos = {
});
},
/**
* Get advanced informations about a user
*
* @param {Integer} userID The ID of the user to fetch
* @param {Function} callback What to do once we got the information
*/
getAdvancedInfos: function(userID, callback){
//Prepare an API request
var apiURI = "user/getAdvancedUserInfos";
var params = {
userID: userID
};
//Perform the request
ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, callback);
},
/**
* Get the user ID specified by its folder name
*

View File

@ -32,25 +32,29 @@ $config['CSSfiles'] = array(
"%PATH_ASSETS%css/common/network/networkError.css",
//Components stylesheets
//Menubar stylesheet
"%PATH_ASSETS%css/components/menuBar.css",
//Menubar stylesheet
"%PATH_ASSETS%css/components/menuBar.css",
//Searchform stylesheet
"%PATH_ASSETS%css/components/searchForm.css",
//Searchform stylesheet
"%PATH_ASSETS%css/components/searchForm.css",
//Friendbar stylesheet
"%PATH_ASSETS%css/components/friends/friendsBar.css",
//Friendbar stylesheet
"%PATH_ASSETS%css/components/friends/friendsBar.css",
//Conversations stylesheet
"%PATH_ASSETS%css/components/conversations/manager.css",
"%PATH_ASSETS%css/components/conversations/windows.css",
"%PATH_ASSETS%css/components/conversations/list.css",
//Conversations stylesheet
"%PATH_ASSETS%css/components/conversations/manager.css",
"%PATH_ASSETS%css/components/conversations/windows.css",
"%PATH_ASSETS%css/components/conversations/list.css",
//User selector stylesheet
"%PATH_ASSETS%css/components/userSelect/userSelect.css",
//User selector stylesheet
"%PATH_ASSETS%css/components/userSelect/userSelect.css",
//Emojies
//Emojies
"%PATH_ASSETS%css/components/emoji/parser.css",
//Pages stylesheets
//User Page
"%PATH_ASSETS%css/pages/userPage/accessForbidden.css",
);
//3rd party JS files to include (at the end of the page)
@ -170,6 +174,7 @@ $config['JSfiles'] = array(
//User page
"%PATH_ASSETS%js/pages/userPage/main.js",
"%PATH_ASSETS%js/pages/userPage/accessForbidden.js",
//Login page
"%PATH_ASSETS%js/pages/login.js",