Roundcube Community Forum

Release Support => Older Versions => 0.1 beta 2 => Topic started by: sirola on October 10, 2006, 09:48:28 AM

Title: Need help with auto login or auto signup !
Post by: sirola on October 10, 2006, 09:48:28 AM
Hello,

Is there any way I can pass parameters "username" and "password" to default RoundCube index.php file. I am trying to avoid login screen, because I know username and password and just want user to be redirected automatically to his/her mail account. Because I work mostly with ASP.NET and C#, I don't know PHP very good.

I have tried something like this:
http://mailserver.com/roundcube/index.php?_user=username&_pass=password
but I got login screen again.

Can somebody please help me with this.
Is that possible and if it is what I have to change and how to call URL for RoundCube webmail site.

So I need to avoid somehow login screen, I have "username" and "password" and want to be redirected to mail account promptly without entering username and password in text boxes.

By the way RoundCube is great, AJAX style, design, features, great work.

Regards to all,

Sirola
osirola@inet.hr

-----------------------------------------
hMailServer 4.2.1-B197 integrated MySQL
roundcubemail-0.1beta2
Windows 2003 Server, IIS 6.0
-----------------------------------------
Title: Re: Need help with auto login or auto signup !
Post by: helga on October 12, 2006, 07:43:22 AM
search in index.php:

Code: [Select]
else if (isset($_POST['_user']) && isset($_POST['_pass']) &&
      rcmail_login(get_input_value('_user', RCUBE_INPUT_POST), $_POST['_pass'], $host))
  {

change to:

Code: [Select]
else if (isset($_REQUEST['_user']) && isset($_REQUEST['_pass']) &&
      rcmail_login(get_input_value('_user', RCUBE_INPUT_POST), $_REQUEST['_pass'], $host))
  {
Title: Re: Need help with auto login or auto signup !
Post by: luizbox on November 01, 2006, 04:22:46 PM
I need the same fix for my pages, but this displayed here don't give right... Had something else that need to be configured for work!?
Title: Re: Need help with auto login or auto signup !
Post by: MylesHawkins on November 28, 2006, 11:15:38 AM
After changing the $_POST's to $_REQUEST's you need to pass it a url like:

http://mailserver.com/roundcube/index.php?_user=[YOURUSERNAMEHERE]&&_pass=[YOURPASSWORDHERE]&&_action=login"
Title: Re: Need help with auto login or auto signup !
Post by: Octavius on February 14, 2007, 04:46:04 AM
Hello, Many thanks for this superb Webmail. I'm trying to pass login and password parameters like explained in this post but it's not working. I'm using the last version of Round Cube.

Could you please help me ?

Many many thanks,

Steve.
Title: Re: Need help with auto login or auto signup !
Post by: road on February 21, 2007, 01:39:43 PM
We actually made our own form and posted it to round cube automatically with javascript. Basically they had already logged in so we can use the same credentials. We are using coldfusion but you can translate the idea to anything you want. This is a form we added to the roundcube root directory.



   
      
      
      
   

   


Title: Re: Need help with auto login or auto signup !
Post by: Octavius on March 08, 2007, 09:34:10 AM
Hello Road, many thanks for your help. I will try your solution.
But i'm wondering if it's not possible to pass parameters in the URL like in this solution :

http://mailserver.com/roundcube/index.php?_user=[YOURUSERNAMEHERE]&&_pass=[YOURPASSWORDHERE]&&_action=login"

Many thanks,

Octavius.
Title: Re: Need help with auto login or auto signup !
Post by: Stevie on March 10, 2007, 12:58:39 PM
You have to pass the parameters like that.

The only other way you can do this is via PHP. That way your details are secure as they cannot be seen.

road's way would be like this in pure HTML.

Code: [Select]
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;[url]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>[/url]
<html xmlns=&quot;[url]http://www.w3.org/1999/xhtml&quot;>[/url]
<head>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; />
<title>Logging You In..</title>
</head>

<body onload=&quot;document.rcLogin.submit();&quot;>
<center>Please Wait..</center>
<form id=&quot;rcLogin&quot; name=&quot;rcLogin&quot; method=&quot;post&quot; action=&quot;[url]https://neoboffinhosting.com/webmail/rc/&quot;>[/url]
<input type=&quot;hidden&quot; name=&quot;_action&quot; value=&quot;login&quot; />
<input type=&quot;hidden&quot; name=&quot;_user&quot; value=&quot;type_ya_email_here&quot; />
<input type=&quot;hidden&quot; name=&quot;_pass&quot; value=&quot;type_ya_password_here&quot; />
</form>
</body>
</html>
Title: Re: Need help with auto login or auto signup !
Post by: Octavius on March 14, 2007, 06:56:28 AM
Stevie, you're the best !!! it's working.

Many thanks for your help, I will try with PHP variables.

Have a nice day,

Steve.
Title: Re: Need help with auto login or auto signup !
Post by: aclertant on March 15, 2007, 06:50:33 AM
Hello,

I tried the Stevie solution and it work almost for me but i use something not elegant.

Do I need to change $_request to $_post too ?

So I have a page with few tabs and one of them open an Iframe with : src="test.html"
In test.html I put only the Stevie script.

It work in IE but not in Firefox (display just "Please wait...")

If I load directly test.html it's almost the same, work well in IE, but at the first load of test.html in firefox RC display an erreur (your browser does not accept cookies) if I reload the test.html it's working ???

Any idea ?

Thanks for your help.
Title: Re: Need help with auto login or auto signup !
Post by: Stevie on March 15, 2007, 06:58:18 AM
Possibly your Cookie settings in FireFox..

Check them to see if you have enabled cookies.

You don't need to change anything RoundCube using my solution.
Title: Re: Need help with auto login or auto signup !
Post by: aclertant on March 15, 2007, 09:15:57 AM
Hello Stevie,

I tried a lot of things but nothing success realy.

You look like a good developper ;) your tip is nice and work well, and that my fault if your code dont work.

So that why I ask you what do you think about my problem and what would be the best way to do something like this
(http://itineris1.free.fr/example.jpg)

My main page will be turn to a php page with (or not I hope not) an iframe to display the RC.

ps: My tabs is a switch div not an ajax call

Thanks you very much, Andre
Title: Re: Need help with auto login or auto signup !
Post by: Stevie on March 15, 2007, 10:10:28 AM
If you try to include RoundCube directly into a PHP page, your styles (CSS) will get messed up for a start. Then if the developer of RoundCube has made it so that it can work via an include it should run fine and all you need to worry about is the CSS styles.

However, should it not, you've got alot of re-coding todo.

Your best method is actually an iframe as this will work like normal.

For me, this works:

Code: [Select]
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;[url]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>[/url]
<html xmlns=&quot;[url]http://www.w3.org/1999/xhtml&quot;>[/url]
<head>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; />
<title>Please Login</title>
</head>

<body>
<center>
<form id=&quot;rcLogin&quot; name=&quot;rcLogin&quot; method=&quot;post&quot; action=&quot;[url]https://neoboffinhosting.com/webmail/rc/&quot;[/url] target=&quot;rcFrame&quot;>
<input type=&quot;hidden&quot; name=&quot;_action&quot; value=&quot;login&quot; />
Email: <input type=&quot;text&quot; name=&quot;_user&quot; />
Password: <input type=&quot;password&quot; name=&quot;_pass&quot; />
<input name=&quot;Submit&quot; type=&quot;submit&quot; value=&quot;Submit&quot; />
</form>
<br /><br />
<iframe src=&quot;[url]https://neoboffinhosting.com/webmail/rc/&quot;[/url] id=&quot;rcFrame&quot; name=&quot;rcFrame&quot; frameborder=&quot;0&quot; height=&quot;550&quot; width=&quot;700&quot;>Your browser doesn't support iframes.</iframe>
</center>
</body>
</html>

As does this (just an iframe):

Code: [Select]
[/url]
[/url]


Please Login







Title: Re: Need help with auto login or auto signup !
Post by: aclertant on March 15, 2007, 11:51:46 AM
Thank you very much Stevie for spendind time to help me.

Actualy I need both iframe and auto login and I think I got a session trouble because the session id cant be read by my main page, but let my try to put my code as you do :P

main.html
Code: [Select]
<html>
<head></head>
<body>
<iframe id=&quot;rcframe&quot; name=&quot;rcframe&quot; src=&quot;test.html&quot; marginheight=&quot;0px&quot; marginwidth=&quot;0px&quot; height=&quot;500px&quot; width=&quot;720px&quot; frameborder=&quot;0&quot;></iframe>
</body>
</html>

test.html
Code: [Select]
[/url]
[/url]


Logging You In..


Please Wait..

[/url]







The code I reply is working :'( Because I tried to upload a page like the main.html here and it's work, but mine is not so simple of course...

I'll try to cut some others scripts in my big main.html and come back.

An other way could be to create a session in the main.html php ;)
And try to load an iframe src="http://www.mydomain.co.uk/webmail/index.php" by a normal way...

if the session is set already, RC should detect it and go to ?task=mail ?? no?

Any idea to do this ? (I know it's a big challenge)

Did you found somethings wrong in what Im replying ?

Many many thanks Stevie :)
sincerly, Andre
Title: Re: Need help with auto login or auto signup !
Post by: Stevie on March 15, 2007, 12:18:14 PM
This is a quote from a forum. Unfortunatley, I'm too busy to mess around with the code to build something for you. However, if you understand it, you might be able to build it yourself.

Code: [Select]
you may try to do a little trick:
on the main page form submit you open up a temporary window where you can store in javascript the variables that you posted. Then once the main page is loaded with the target page, you grab into javascript the values from the temporary window and close it.
Not so elegant but should work.
Title: Re: Need help with auto login or auto signup !
Post by: aclertant on March 15, 2007, 05:04:54 PM
hello Stevie,

I tried to simplify my process and I'm not sure if your script work well :-[
Because on a simple page like that :
test.html
Code: [Select]
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;[url]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>[/url]
<html xmlns=&quot;[url]http://www.w3.org/1999/xhtml&quot;>[/url]
<head>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; />
<title>Logging You In..</title>
</head>
<body onload=&quot;document.login.submit();&quot;>
<center>Please Wait..</center>
<form id=&quot;login&quot; name=&quot;login&quot; method=&quot;post&quot; action=&quot;[url]http://www.mydomain.com/webmail/index.php&quot;>[/url]
<input type=&quot;hidden&quot; name=&quot;_action&quot; value=&quot;login&quot; />
<input type=&quot;hidden&quot; name=&quot;_user&quot; value=&quot;itineris1&quot; />
<input type=&quot;hidden&quot; name=&quot;_pass&quot; value=&quot;itineris&quot; />
</form>
</body>
</html>

I got the "your browser does not accept cookies" message.
And I try from a new computer with IE7 and FF both failled.

But if you retry the test.html url (and leave the index webmail) then it work ...

It mean that at the first load his make the cookie and display the erreur, and the second time every things work well :P


May I ask you again ::) I realy would love to see this webmail working.

sincerly Andre
Title: Re: Need help with auto login or auto signup !
Post by: aclertant on March 19, 2007, 06:56:24 AM
Hello,

So I look at the RC process and I found the solution 8)

The Stevie script is almost good ;) just miss a small thing because in the index.php of RC there is a test about session.. so that why sometimes it's work (because a session steal activate) or not if there is no session able.

This script is working for me as well inside an IFRAME under IE and FF and on a new computer with db empty.

test.php (ya must be php)
Code: [Select]
<?php
session_start
();
session_register(&quot;user_id&quot;);
$_SESSION['user_id'] = '';
?>

<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;[url]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>[/url]
<html xmlns=&quot;[url]http://www.w3.org/1999/xhtml&quot;>[/url]
<head>
<title>welcome</title>
</head>
<body onload=&quot;document.form.submit();&quot;>
<form name=&quot;form&quot; action=&quot;[url]http://www.yourdomain.com/webmail/&quot;[/url] method=&quot;post&quot;>
<input name=&quot;_action&quot; value=&quot;login&quot; type=&quot;hidden&quot; />
<input type=&quot;hidden&quot; id=&quot;rcmloginuser&quot; name=&quot;_user&quot; value=&quot;your_login&quot; />
<input type=&quot;hidden&quot; id=&quot;rcmloginpwd&quot; name=&quot;_pass&quot; value=&quot;your_pwd&quot; />
</form>
</body>
</html>

Actualy I'm using this in an Iframe like this.



test.php
Code: [Select]
session_start();
session_register("user_id");
$_SESSION['user_id'] = '';

$mylogin = $_GET['mylogin'];
$mypwd = $_GET['mypwd'];
?>
[/url]
[/url]

welcome




" />
" />



Thanks you very much Stevie you was first on the good way ;)
Hope this help you
André
Title: Re: Need help with auto login or auto signup !
Post by: Bradleyenator on March 19, 2007, 10:48:44 PM
Quote from: helga
search in index.php:

Code: [Select]
else if (isset($_POST['_user']) && isset($_POST['_pass']) &&
      rcmail_login(get_input_value('_user', RCUBE_INPUT_POST), $_POST['_pass'], $host))
  {

change to:

Code: [Select]
else if (isset($_REQUEST['_user']) && isset($_REQUEST['_pass']) &&
      rcmail_login(get_input_value('_user', RCUBE_INPUT_POST), $_REQUEST['_pass'], $host))
  {

Actually you also need to make another small change for this to work. You need to change the RCUBE_INPUT_POST to GET
But then that means that if you login via the normal form it doesn't work. So below is what I did.

Code: [Select]
// try to log in
if ($_action=='login' && $_task=='mail') {
 $host = rcmail_autoselect_host();
 
 // check if client supports cookies
 if (empty($_COOKIE)) {
  show_message("cookiesdisabled", 'warning');

 } else if (isset($_REQUEST['_user']) && isset($_REQUEST['_pass'])) {
//Check Auth Details.
if (rcmail_login(get_input_value('_user', RCUBE_INPUT_POST), get_input_value('_pass', RCUBE_INPUT_POST, true, 'ISO-8859-1'), $host)) {
// send redirect
  header("Location: $COMM_PATH");
  exit;
} elseif (rcmail_login(get_input_value('_user', RCUBE_INPUT_GET), get_input_value('_pass', RCUBE_INPUT_GET, true, 'ISO-8859-1'), $host)) {
// send redirect
  header("Location: $COMM_PATH");
  exit;
} else {
  show_message("loginfailed", 'warning');
  $_SESSION['user_id'] = '';
}

 } else {
  show_message("loginfailed", 'warning');
  $_SESSION['user_id'] = '';
 }
}

Then you can either login normally or via a link.
Eg: http://domain.com/roundcube/index.php?_user=[USERNAME]&_pass=[PASSWORD]&_action=login

To log the user in automatically I just included RC in an iframe and populated the SRC attribute of the iframe with the correct username and password obtained from MY user database.

That all works fine however due to it being in an Iframe, IE has a heart attack because it is getting a Third Party cookie from RC. I have yet to find a solution to this apart from lowering the Privacy settings in IE to allow Third Party cookies.

Just wondering has anyone got plans for incorporating a P3P Privacy Policy because i believe this would solve the issue.
Title: Re: Need help with auto login or auto signup !
Post by: minoan on March 23, 2007, 09:22:59 AM
The Session:

Code: [Select]
<?php 
session_start
();
session_register(&quot;user_id&quot;);
$_SESSION['user_id'] = ''
?>

Doesn't seem to solve the problem! :-\
Any other suggestions?
Title: Re: Need help with auto login or auto signup !
Post by: minoan on March 23, 2007, 09:32:52 AM
Id did this:
Code: [Select]
// try to log in
if ($_action=='login' && $_task=='mail')
 {
 $host = rcmail_autoselect_host();
 
 // check if client supports cookies
 //if (empty($_COOKIE))
  //{
  //show_message(&quot;cookiesdisabled&quot;, 'warning');
  //}
 //else
  if (isset($_POST['_user']) && isset($_POST['_pass']) &&
      rcmail_login(get_input_value('_user', RCUBE_INPUT_POST),
       get_input_value('_pass', RCUBE_INPUT_POST, true, 'ISO-8859-1'), $host))
  {
  // send redirect
  header(&quot;Location: $COMM_PATH&quot;);
  exit;
  }
 else
  {
  show_message(&quot;loginfailed&quot;, 'warning');
  $_SESSION['user_id'] = '';
  }
 }
Now works perfect but it doesn't check for the cookie! I think that is not something which is needed!
Title: Re: Need help with auto login or auto signup !
Post by: dabbish on October 30, 2007, 09:22:33 AM
http://roundcubeforum.net/forum/index.php?topic=2318.0