Author Topic: Restricted Logins  (Read 5250 times)

Offline jasonq

  • Newbie
  • *
  • Posts: 3
Restricted Logins
« on: July 05, 2009, 12:25:32 AM »
Hello, and congratulations on RC. It really is great, especially for a guy coming from squirrel mail.

I have clients that prefer that their employees not be able to log in via webmail (or any other protocol outside of the local network), but do need to allow certain individuals to login while on trips, etc.

To accomplish this I have modified the rcube_users class to check a table called "allowed_users", which, as you might suspect, contains a list of users that are allowed to log in.  I also added an entry in the /config/main.inc.php file to turn this feature on and off.

My nasty hack has no place in the repository, but I was wondering if this might be something worth adding to the core project, or if you think it's best left alone or maybe implemented as an add-on.

Thanks so much,
Jason Quick

PS..Here's my code:

In rcube_user.php

Code: [Select]
function check_allowed($User) {

        $sql_result = $this->db->query("SELECT `id` FROM `allowed_users` WHERE `username` = '$User'");
        $n_results = $this->db->num_rows($sql_result);

        if ($n_results == 1) {
                return true;
        } else {
                return false;
        }
   }


my addition to the login method in rcmail.php

Code: [Select]
//check if we need to check against allowed users

        if ($config['restrict_users']) {
                //We do need to check them against the db
                $allowed_user = rcube_user::check_allowed($username);
                if (!$allowed_user) {
                        return false;
                }
        }
« Last Edit: July 05, 2009, 01:48:33 AM by jasonq »

Offline bpat1434

  • Administrator
  • Hero Member
  • *****
  • Posts: 673
Restricted Logins
« Reply #1 on: July 05, 2009, 03:57:34 PM »
This feature is a default feature of Roundcube.  If you disable the "auto create user" setting, then you can not log in to webmail unless a user already has a row in the roundcube database.  So then when they want to add a user, you just need to add the email to the users table in roundcube.

Good job on modifying Roundcube though ;)
 
  

Offline jasonq

  • Newbie
  • *
  • Posts: 3
Restricted Logins
« Reply #2 on: July 05, 2009, 04:38:30 PM »
That makes sense. You know, I had a feeling I was going to end up feeling silly on that one...

Thanks,
Jason Quick