Users running a non-download version of Vanilla (pulled from github), on branch release/2019.016 or master from the last 2 weeks should upgrade to release/2019.017 or latest master for security reasons. Downloaded official open sources releases are not affected.

Hide profile from guests.

This discussion is related to the MyProfile addon.
AnonymooseAnonymoose ✭✭
edited October 2012 in Feedback
public function ProfileController_MyProfile_Create($Sender, $Args) {

       // Check to see if guest.
       if(Gdn::Session()->UserID == 0){
         return FALSE;}

Added this code to hide from all guests.

Comments

  • phreakphreak Vanilla*APP (White Label) & Vanilla*Skins Shop MVP
    edited March 2013

    @Anonymoose:
    This seems to lead to a blank page. So probably not the best way.
    I added your code on line 60 in the file ~/plugins/MyProfile/default.php

    • VanillaAPP | iOS & Android App for Vanilla - White label app for Vanilla Forums OS
    • VanillaSkins | Plugins, Themes, Graphics and Custom Development for Vanilla
  • use

    throw NotFoundException();

    grep is your friend.

    UnderDoglifeisfoo
  • phreakphreak Vanilla*APP (White Label) & Vanilla*Skins Shop MVP

    @x00: Is it possible to hide it from guests? Where do i need to place "throw NotFoundException();" ?

    Thanx

    • VanillaAPP | iOS & Android App for Vanilla - White label app for Vanilla Forums OS
    • VanillaSkins | Plugins, Themes, Graphics and Custom Development for Vanilla
  • peregrineperegrine MVP
    edited March 2013
    add the if below this function to prevent the tab showing for non-logged in users.
    
        public function ProfileController_AddProfileTabs_handler($Sender) {
             if(Gdn::Session()->UserID < 1) return;
    
    
    add this if statement  to prevent someone from viewing the link if they know the link 
    
        public function ProfileController_MyProfile_Create($Sender, $Args) {
        if (Gdn::Session()->UserID < 1)   throw NotFoundException();
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    phreak
  • phreakphreak Vanilla*APP (White Label) & Vanilla*Skins Shop MVP
    edited March 2013

    Thank you peregrine. Works great. By UserID < 1 looks like a logical work around. Just logically this can be done by asking for the role also or?

    • VanillaAPP | iOS & Android App for Vanilla - White label app for Vanilla Forums OS
    • VanillaSkins | Plugins, Themes, Graphics and Custom Development for Vanilla
  • peregrineperegrine MVP
    edited March 2013

    Not necessarily - a user can have many roles, then you will have a jungle of testing.

    If the user is not logged in they have session user id of 0 and are therefore guests.

    Although some people have userid of 0 as root in their tables - I think this is an artifact of migrations. and they really shouldn't have a userid of 0 in the user table.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    phreak
  • phreakphreak Vanilla*APP (White Label) & Vanilla*Skins Shop MVP

    Ah ok, thanx peregrine. Knowledge is power. :)

    • VanillaAPP | iOS & Android App for Vanilla - White label app for Vanilla Forums OS
    • VanillaSkins | Plugins, Themes, Graphics and Custom Development for Vanilla
Sign In or Register to comment.