Jump to:

23493 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » SS 2.4.7 _config.php permission check

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 359 Views
  • dacar
    Avatar
    Community Member
    168 Posts

    SS 2.4.7 _config.php permission check Link to this post

    Hi,

    does anybody know, how to do a permission check in _config.php to load differet database settings depending on the login status?

    global $databaseConfig;
    if (Member::isInGroup('Administratoren')) {
       // temoräre DB
       $databaseConfig = array(
          "type" => 'MySQLDatabase',
          "server" => 'mysql5.xxx.net',
          "username" => 'yyy',
          "password" => 'yyy',
          "database" => 'yyy',
          "path" => '',
       );
    } else {
       // orig DB
       $databaseConfig = array(
          "type" => 'MySQLDatabase',
          "server" => 'mysql5.xxx.net',
          "username" => 'xxx',
          "password" => 'xxx',
          "database" => 'xxx',
          "path" => '',
       );
    }

    Greetings, Carsten.

  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: SS 2.4.7 _config.php permission check Link to this post

    OK - basically the user needs to login first, so that would mean his credentials are checked against database yyy - because at that point he hasn't logged in yet.

    Once logged in however - even if the users status would already be known at the moment the config file is read, which it probably isn't, because SS would first have to check the user against the users credentials in, yes, the database, to make sure it's a valid login - SS would now have to check same users credentials against database xxx... or... From this point on I get too dizzy

    Every other way, like checking on a session cookie and logging the user onto the second database based on that, seems to me to be very unsafe...

    Of course I don't know why you need to do this, but maybe there is another approach that would solve your problem?

    Martine

  • dacar
    Avatar
    Community Member
    168 Posts

    Re: SS 2.4.7 _config.php permission check Link to this post

    Hi martimiz,

    thanks for your fast reply. This one was absolutely project specific. I wanted to give the authors the possibility to change the content, images and DO's fundamentally while useres see the old content. After the work is done i wanted to change the DB No.2 to the leading DB.

    I have solved the problem in an other way but i am still keen on knowing whether it is possible to solve it in the suggested way.

    Thanks.

    359 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.