Redirecting external login/logout

Discussion forum for MOD Writers regarding MOD Development.
Locked
Maglok
Registered User
Posts: 10
Joined: Tue Jan 26, 2010 2:11 pm

Redirecting external login/logout

Post by Maglok »

First time poster, long time lurker here. Hello!

I have a perfectly well running phpbb3 fully up to date. I am trying to create a logout/login outside of the forum (basically the site itself). This works quite well I can login or logout, I just cannot seem to get phpbb3 to redirect to the page the person came from afterwards.

The URL I generate for logout for example is: http://forum.domain.nl/ucp.php?mode=log ... domain.nl/

This does log me out but does not redirect me. What should I put in that url to get a redirect to work? It would be rather confusing for my users to be redirected to the forum when they logout in the middle of the site.
CancunManny
Registered User
Posts: 54
Joined: Mon Jan 25, 2010 7:32 pm

Re: Redirecting external login/logout

Post by CancunManny »

I am using the code below to login and redirect. My problem is that I want to redirect quicker, as the phpbb3 forum page shows for about 4 seconds before it redirects

Code: Select all

<?php
	$usernameBB = $_POST['ID'] ; 
	$passwordBB = $_POST['Password']  ;
?>

 <form action="../../../Cancun_Forum/ucp.php" method="POST" name="phpbb_login">
	 <input type="hidden" name="username" size="25" maxlength="40" value="<?= $usernameBB ?>" />
	 <input type="hidden" name="password" size="25" maxlength="32" value="<?= $passwordBB ?>" />
	 <input type="hidden" value="Log in" name="login"/>
	 <input type="hidden" name="redirect" value="../member.php" />
</form>	

<script src="inc/js/functions.js"></script>
<script type="text/javascript">
	function doSubmit(){
		document.forms['phpbb_login'].submit();
	}
	addEvent( window, 'load', doSubmit );
</script>


I am now doing research on how to create a "logout" routine, hopefully without having to make it visible to my users. I want my clients to be able to log out of my main site, and automatically be logged out of phpbb3 to. Would killing cookies do this job? Would you mind sharing your function to create your logout link?
Maglok
Registered User
Posts: 10
Joined: Tue Jan 26, 2010 2:11 pm

Re: Redirecting external login/logout

Post by Maglok »

Code: Select all

<a href="http://forum.domain.nl/ucp.php?mode=logout&sid=<?php echo $session_id;?>&redirect=<?php echo current_url(); ?>">Logout</a>
Sadly though adding &redirect is not working.

I do not really understand your code. I mean are you saying that if I feed a POST value to the ucp.php of 'redirect' it will redirect me after login to the page specified?
CancunManny
Registered User
Posts: 54
Joined: Mon Jan 25, 2010 7:32 pm

Re: Redirecting external login/logout

Post by CancunManny »

Hello mate. I am not a good programmer, and don't understand the lingo very well. That function I have placed on the "log in" function for dolphin. When my users log in to dolphin, that function I posted gets called, and it logs my users onto PHPB3, i get a phpbb3 screen for about 4 seconds, then it re directs back into my dolphin site.

Now, by looking at the code, it seems that if you POST it, the redirect does work, at least it is working for me.
Maglok
Registered User
Posts: 10
Joined: Tue Jan 26, 2010 2:11 pm

Re: Redirecting external login/logout

Post by Maglok »

I'll look into it. Thanks for the remarks so far. :)
User avatar
Typo
Former Team Member
Posts: 404
Joined: Tue Dec 30, 2008 6:12 am
Location: USA
Name: Jeremy Lorenzo
Contact:

Re: Redirecting external login/logout

Post by Typo »

Maglok wrote:The URL I generate for logout for example is: http://forum.domain.nl/ucp.php?mode=log ... domain.nl/

This does log me out but does not redirect me. What should I put in that url to get a redirect to work? It would be rather confusing for my users to be redirected to the forum when they logout in the middle of the site.
The problem is that the login_box() function in /includes/functions.php uses the meta_refresh() function to do the redirects and this function only works within site links. To fix this we need to use redirect() instead of meta_refresh().
OPEN:

Code: Select all

includes/functions.php
FIND:

Code: Select all

			$redirect = meta_refresh(3, $redirect);
			trigger_error($message . '<br /><br />' . sprintf($l_redirect, '<a href="' . $redirect . '">', '</a>'));
REPLACE WITH:

Code: Select all

			redirect($redirect);
CancunManny wrote:I am using the code below to login and redirect. My problem is that I want to redirect quicker, as the phpbb3 forum page shows for about 4 seconds before it redirects
The problem here is also linked to the call to the meta_refresh() function from the login_box() function in /includes/functions.php. By default this add's a 3 second delay so it can show the "Login Successfull" screen and then redirect you.

If you want to change the delay for showing that screen that says login successfull, simply:
OPEN:

Code: Select all

includes/functions.php
FIND:

Code: Select all

			$redirect = meta_refresh(3, $redirect);
REPLACE WITH:

Code: Select all

			$redirect = meta_refresh(0, $redirect);
However, if you want to completely remove the page that says "successfully logged in AND take out the delay then you should follow the instructions I placed above for Maglok.


Hope this is some help for you both.

Typo
Maglok
Registered User
Posts: 10
Joined: Tue Jan 26, 2010 2:11 pm

Re: Redirecting external login/logout

Post by Maglok »

Hello Typos,

Very interesting! Thanks. The thing is though that I want to redirect to my page, not neccesarily cut out the splash screen that thanks you for logging in. I used that URL to try to tell phpbb where to redirect to, but that didn't work. I don't see how the change you suggest would make it work? You still use the $redirect option. But I need to know what kind of link to craft to get that redirect url in phpbb.
comkidwizzer3
Registered User
Posts: 375
Joined: Fri Jul 13, 2007 8:24 am
Location: $user->data['user_location'];
Contact:

Re: Redirecting external login/logout

Post by comkidwizzer3 »

Don't do the first edit, just do the second but I would change 0 to maybe 2 seconds, so they can quickly read it ;)
~My MODs~
Login After Register - v1.0.0 | Custom Ranks MOD - RC

~!Hasher!~
Maglok
Registered User
Posts: 10
Joined: Tue Jan 26, 2010 2:11 pm

Re: Redirecting external login/logout

Post by Maglok »

comkidwizzer3 wrote:Don't do the first edit, just do the second but I would change 0 to maybe 2 seconds, so they can quickly read it ;)
Then I would only be changing the time the splash page is displayed. The problem is that the splash page does not redirect to the main page of the site, but to the main page of the forum.
comkidwizzer3
Registered User
Posts: 375
Joined: Fri Jul 13, 2007 8:24 am
Location: $user->data['user_location'];
Contact:

Re: Redirecting external login/logout

Post by comkidwizzer3 »

Then replace with this:

OPEN: includes/functions.php

FIND:

Code: Select all

$redirect = meta_refresh(3, $redirect); 
REPLACE WITH:

Code: Select all

$redirect = meta_refresh(3, 'type in url here', true); 
NOTE: Change the 3 in the find to whatever it is now ;)
~My MODs~
Login After Register - v1.0.0 | Custom Ranks MOD - RC

~!Hasher!~
Maglok
Registered User
Posts: 10
Joined: Tue Jan 26, 2010 2:11 pm

Re: Redirecting external login/logout

Post by Maglok »

Yeah but then it is always going to redirect to that page. If I login from the forum it will also. Also there is the issue of logout to handle.

What I need is a URL I can use to redirect. What is wrong with my URL. Why must I edit sourcecode of the forum to redirect to the page requesting the login?
Locked

Return to “[3.0.x] MOD Writers Discussion”