0

i have Roundcube and i need to change the Login ...

i found only :

<roundcube:form name="form" method="post">
<roundcube:object name="loginform" form="form" size="40" submit=true />

And i have login Script :

 <a class="hiddenanchor" id="toregister"></a>
                    <a class="hiddenanchor" id="tologin"></a>
                    <div id="wrapper">
                        <div id="login" class="animate form">
                            <form  action="?????.php" method="post"> 
                                <h1>Webmail Login</h1> 
                                <p> 
                                    <label for="username" class="uname" data-icon="u" > Email </label>
                                    <input id="username" name="username" required="required" type="text" placeholder="papduser@domain.us"/>
                                </p>
                                <p> 
                                    <label for="password" class="youpasswd" data-icon="p"> Passwort </label>
                                    <input id="password" name="password" required="required" type="password" placeholder="eg. X8df!90EO" /> 
                                </p>
                                <p class="keeplogin"> 
         <input type="checkbox" name="loginkeeping" id="loginkeeping" value="loginkeeping" /> 
         <label for="loginkeeping">Keep me logged in</label>
        </p>
                                <p class="login button"> 
                                    <input type="submit" value="Login" /> 
        </p>
                                <p class="change_link">
         Noch kein Mitglied ?
         <a href="#toregister" class="register">Registrieren</a>
        </p>
                            </form>
                        </div>

I have Activate the "autologon" Plugin.

What i need now?

2 Answers2

2

Note: Working on RoundCube 1.4.11 Version.

Step 1: Update config.inc.php

Update Plugin
$config['plugins'] = array('autologon');
Realpath: ROUNDCUBE/config/config.inc.php


Step 2: Update autologon.php
Realpath: ROUNDCUBE/plugins/autologon/autologon.php

function authenticate($args)
  {       
    if (!empty($_POST['_autologin']) && $this->is_localhost()) {
      $args['user'] = $_POST['_user'];
      $args['pass'] = $_POST['_pass'];
      $args['host'] = 'ssl://mail.YOUR DOMAIN NAME.com';
      $args['cookiecheck'] = false;
      $args['valid'] = true;
    } 
    return $args;
  }

Step 3: Update index.php
Update this code before this line
Realpath: ROUNDCUBE/index.php

if ($auth['valid'] && !$auth['abort'] && $RCMAIL->login($auth['user'], $auth['pass'], $auth['host'], $auth['cookiecheck'])) {

Code here This process makes the Authentication Validation to true if the Username and Password is to post
Try More Custom Condition for more if you want

        // Custom Code
        {
        
            // if login detail post and check post server detail
            if( $RCMAIL->login($auth['user'], $auth['pass']) && $_POST['_user'] && !empty($_POST['_user']) && $_POST['_pass'] && !empty($_POST['_pass']) ){
                $auth['valid'] = true;
                $auth['abort'] = false;
            }
        
        }

Step 4: Create form for POST data to index.php

<form name="form" action="//YOUR DOMAIN NAME.com/index.php" method="post">
    <input type="hidden" name="_action" value="login" />
    <input type="hidden" name="_task" value="login" />
    <input type="hidden" name="_autologin" value="1" />
    <table>
        <tr>
            <td>Utente</td>
            <td><input name="_user" id="rcmloginuser" value="" type="text" /></td>
        </tr>
        <tr>
            <td>Password</td>
            <td><input name="_pass" id="rcmloginpwd" type="password" /></td>
        </tr>
        <tr>
            <td colspan="2"><input type="submit" value="Login" /></td>
        </tr>
    </table>
</form>
1

I use RoundcubeAutoLogin class to auto login: https://github.com/alexjeen/Roundcube-AutoLogin

And I call it like this:

require_once 'RoundcubeAutoLogin.php';

$rc = new RoundcubeAutoLogin('http://your_domain/roundcube/'); // set your roundcube domain path

$cookies = $rc->login('your_email@domain.com', 'email_password');

// now you can set the cookies with setcookie php function, or using any other function of a framework you are using

foreach($cookies as $cookie_name => $cookie_value)
{
    setcookie($cookie_name, $cookie_value, 0, '/', '');
}
// and redirect to roundcube with the set cookies
$rc->redirect();

I hope that this will help you

jere_hr
  • 284
  • 3
  • 11