diff --git a/assets/css/pages/userPage/accessForbidden.css b/assets/css/pages/userPage/accessForbidden.css index 5eec29b2..5fa25079 100644 --- a/assets/css/pages/userPage/accessForbidden.css +++ b/assets/css/pages/userPage/accessForbidden.css @@ -5,10 +5,19 @@ */ /** - * Callout special stylesheet + * User signed out */ -.user_page_access_forbidden { +.user_access_denied_signed_out { margin: auto; margin-top: 30px; max-width: 500px; +} + +/** + * User signed in + */ +.box-user-access-denied { + margin: auto; + margin-top: 30px; + max-width: 350px; } \ No newline at end of file diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index c2fdbcd6..fc3f8851 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -687,9 +687,14 @@ var ComunicWeb = { /** * Display the page for user with forbidden access */ - display: function(id, params, target){} + display: function(id, params, target){}, - } + /** + * Show basic user informations + */ + showBasicInfos: function(userInfos, target){}, + + }, }, diff --git a/assets/js/pages/userPage/accessForbidden.js b/assets/js/pages/userPage/accessForbidden.js index 8c1c277e..faf9af0b 100644 --- a/assets/js/pages/userPage/accessForbidden.js +++ b/assets/js/pages/userPage/accessForbidden.js @@ -27,12 +27,90 @@ ComunicWeb.pages.userPage.accessForbidden = { "danger" ); - elem.className += " user_page_access_forbidden"; + elem.className += " user_access_denied_signed_out"; target.appendChild(elem); + return; + } + //Fetch informations about the user + ComunicWeb.user.userInfos.getUserInfos(id, function(userinfos){ + + //Check for errors + if(userinfos.error){ + + //Inform user it is impossible for him to access this page + elem = ComunicWeb.common.messages.createCalloutElem( + "Access denied", + "You don't have the right to access this page.", + "danger" + ); + + elem.className += " user_access_denied_signed_out"; + + target.appendChild(elem); + + return; + } + + //Show a dialog with basic user informations + ComunicWeb.pages.userPage.accessForbidden.showBasicInfos(userinfos, target); + + + }); + }, + /** + * Show basic user informations + * + * @param {Object} userInfos Informations about the user to display + * @param {HTMLElement} target Target element for user informations + */ + showBasicInfos: function(userInfos, target){ + + //Create box root + var boxRoot = createElem2({ + appendTo: target, + type: "div", + class: "box box-primary box-user-access-denied" + }); + + //Create box body + var boxBody = createElem2({ + appendTo: boxRoot, + class: "box-body box-profile", + type: "div" + }); + + //Add user profile image + var profileImage = createElem2({ + appendTo: boxBody, + type: "img", + class: "profile-user-img img-responsive img-circle", + src: userInfos.accountImage, + }); + + //Add user name + var userName = createElem2({ + appendTo: boxBody, + type:"h3", + class: "profile-username text-center", + innerHTML: userInfos.firstName + " " + userInfos.lastName, + }); + + //Add a message to inform access to the page was denied + var infosMsg = createElem2({ + appendTo: boxBody, + type: "p", + class: "text-center", + innerHTML: "This account is private." + }); + + //Add friendship request message + + } + } \ No newline at end of file