External login stopped working after update

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
AyaB
Registered User
Posts: 50
Joined: Mon Jan 21, 2008 3:43 pm

External login stopped working after update

Post by AyaB »

What version of phpBB are you using? phpBB 3.3.7
What is your board's URL? Currenly working on localhost
How did you install your board? I used the download package from phpBB.com
What is the most recent action performed on your board? Updated from 3.1.x to 3.3.7
Do you have any MODs installed? No
Do you have any extensions installed? No
What styles do you currently have installed? Prosilver
What language(s) is your board currently using? Spanish
Which database type/version are you using? MySQL 8.0.27
What is your level of experience? Comfortable with PHP and phpBB
PHP version: 7.4.26
Please describe your problem. I have an external login form for my phpBB board, I recently updated from 3.1.x to 3.3.7 and it stopped working. I get "The submitted form was invalid" message.


This is at the top of my script:

Code: Select all

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './foro/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

And this is my form code:

Code: Select all

<div id="loginbox">		
	<div class="form-login">
		<form action="foro/ucp.php?mode=login" target="_top" method="post" enctype="application/x-www-form-urlencoded">
		<label class="form-user" for="username">User</label>
		<input type="text" name="username" id="username" /><br />
		<label class="form-password" for="password">Password</label>
		<input type="password" name="password" id="password" />
		<button type="submit" class="buton-login" name="login">Login</button>
		</form>
		<span><a href="foro/ucp.php?mode=sendpassword">Recover password</a></span>
	</div>				
</div>	
I have searched the forum and the only thing I have found is that a "token" is now required to login, but I can't find how to do it.

In the past this site had a wikia with tutorials explaining in detail the process to integrate phpBB into your site, but it doesn't seem to exist anymore.
Last edited by Mick on Fri Jun 24, 2022 2:23 pm, edited 1 time in total.
Reason: Solved.
AyaB
Registered User
Posts: 50
Joined: Mon Jan 21, 2008 3:43 pm

Re: External login stopped working after update

Post by AyaB »

Finally managed to solve it myself, I leave the code to create the token in case someone else needs it in the future:

Code: Select all

$form_name = 'login';
$now = time();
$token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : '';
$token = sha1($now . $user->data['user_form_salt'] . $form_name . $token_sid);
$form_token = '<input type="hidden" name="creation_time" value="' . $now . '" /><input type="hidden" name="form_token" value="' . $token . '" />';
And then echo $form_token before </form>
Swanny
Registered User
Posts: 486
Joined: Sun Apr 14, 2002 2:11 am
Location: Canada

Re: External login stopped working after update

Post by Swanny »

Thanks for this. I have a few forums to update, one of which uses external login for another area of my site. I will test it out but can I switch the code over while still running 3.3.7 and then upgrade or do I have to do it after I update phpBB?
Post Reply

Return to “phpBB Custom Coding”