Author Topic: External login php script  (Read 6192 times)

Offline henkjanklok

  • Newbie
  • *
  • Posts: 2
External login php script
« on: February 20, 2012, 06:11:41 AM »
Hello,

I'm using RC 0.7 but i will a login script in PHP. I'm using the following code but it doesn't work:

Form:
<form name="webmail" action="http://www.mywebsite.nl/webmail/index.php" method="post">

    <
input name="_action" value="login" type="hidden" />
    <
input name="_task" value="login" type="hidden" />
    <
input name="_timezone" id="rcmlogintz" value="_default_" type="hidden" />
    <
input name="ajax" value="1" type="hidden" />
        
    
User <input name="_user" type="text" value="my@mail.com"/>

    
Pass <input name="_pass" type="password" value="my_password" />

        
    <
input type="submit">

</
form>


And i have activate the auto_logon script in the main.inc, and this is the code of the autologon.php
:
class autologon extends rcube_plugin
{
  public 
$task 'login';

  function 
init()
  {
    
$this->add_hook('startup', array($this'startup'));
    
$this->add_hook('authenticate', array($this'authenticate'));
  }

  function 
startup($args)
  {
    
$rcmail rcmail::get_instance();

    if (empty(
$_SESSION['user_id']) && !empty($_GET['_autologin']))
      
$args['action'] = 'login';

    return 
$args;
  }

  function 
authenticate($args)
  {
    if (!empty(
$_GET['_autologin'])) {
      
$args['user'] = $_GET['user'];
      
$args['pass'] = $_GET['pass'];
      
$args['valid'] = true;
      
$args['cookiecheck'] = false;
    }

    return 
$args;
  }
}


The page give the following result: "Invalid request! No data was saved.".

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,505
    • http://SKaero.com/
External login php script
« Reply #1 on: February 20, 2012, 11:22:52 AM »
In the auto login plugin you need need to switch all of the $_GET to $_POST since your posting the data.

Offline henkjanklok

  • Newbie
  • *
  • Posts: 2
External login php script
« Reply #2 on: February 27, 2012, 07:56:27 AM »
It doesn't work, the error is the same.

Offline logone

  • Newbie
  • *
  • Posts: 1
Re: External login php script
« Reply #3 on: April 03, 2012, 05:05:04 PM »
Do you have succes to work this plug in i have the same error ?

Offline corbosman

  • Sr. Member
  • ****
  • Posts: 260
Re: External login php script
« Reply #4 on: April 26, 2012, 03:36:31 AM »
You need to do something with _autologin. You're checking if it exists in $_GET, but then you have to use it in your URL or POST it.

So you could http://www.mywebsite.nl/webmail/index.php?_autologin=1 or add a hidden POST var called _autologin


Offline teebsd

  • Newbie
  • *
  • Posts: 5
Re: External login php script
« Reply #5 on: January 24, 2014, 09:05:57 PM »
I finally made that. Check it out in my gist. https://gist.github.com/TeeBSD/8610622

Just make a patch.

PS: I need a job.