MyBB Community Forums

Full Version: Python Flask & myBB Integration
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hiring a developer to do this for me. I will pay you for this job via PayPal

I'm creating a website using Python Flask and will be using SQLite3 for the database. I want to integrate a forum into the site preferably using myBB but I want it so that users registering on my site will already have an account/logged in on the forum. Problem is the forum will be on a different host as my Python Host does not support PHP files. If you need any more information, please do reply here or PM me Smile
So you need a bridge for the registration process or you like to merge already exists members. A bridge is a fast and easy thing to code. But if you like to merge exists users this will be a bit complexer. Causing the encrypted passwords... (i realy hope you store them encrypted) if not then a merge will be easy to xD
(2017-07-05, 11:37 AM)broatcast Wrote: [ -> ]So you need a bridge for the registration process or you like to merge already exists members. A bridge is a fast and easy thing to code. But if you like to merge exists users this will be a bit complexer. Causing the encrypted passwords... (i realy hope you store them encrypted) if not then a merge will be easy to xD

The website is still under development so there are only a few accounts that I have created. These can be deleted and re-registered. I need a bridge for the registration process. Yes they are encrypted Big Grin
Wrote you an PM.
Managed to sort out the problem myself. Thread can be closed Smile
(2017-07-06, 06:50 PM)kingcool52 Wrote: [ -> ]Managed to sort out the problem myself. Thread can be closed Smile

Mind posting what you did in here to help out people with similar problems in the future?
Hey write a plugin for him this weekend.
It's the decision of kingcool52 if he is willed to let me make it public or not ^^.
(2017-07-07, 12:46 AM)fizz Wrote: [ -> ]
(2017-07-06, 06:50 PM)kingcool52 Wrote: [ -> ]Managed to sort out the problem myself. Thread can be closed Smile

Mind posting what you did in here to help out people with similar problems in the future?
What I did was allow remote access for the mybb database. I had my own registration code for my website so what I did was create another insert SQL query for the mybb_users table. That's it.

The logged in problem will be something I need to look at but the registration on both the website and forum now works
(2017-07-07, 08:30 AM)kingcool52 Wrote: [ -> ]
(2017-07-07, 12:46 AM)fizz Wrote: [ -> ]Mind posting what you did in here to help out people with similar problems in the future?
What I did was allow remote access for the mybb database. I had my own registration code for my website so what I did was create another insert SQL query for the mybb_users table. That's it.

The logged in problem will be something I need to look at but the registration on both the website and forum now works

I gotcha, cool! Login I don't think should be too bad, granted I don't know how your flask authentication works. But on MyBB's end it's pretty simple, the only part you really have to code yourself is the functionality that securely checks the user's login info against the mybb db. This logs a user in (obviously it doesn't validate their password or anything, you'll have to add that) and it's pretty simple:
$username = 'example';

$q = $db->simple_select('users', 'uid,loginkey', "username = '$username'");
        if($db->num_rows($q) == 1)
        {
            $user = $db->fetch_array($q);
            if(!$user['uid'])
                return false;
            // Delete all the old sessions from user's IP address
            $db->delete_query('sessions', "ip='".$db->escape_string($session->ipaddress)."' AND sid != '{$session->sid}'");
            // Create a new session
            $db->update_query('sessions', array('uid'=>$user['uid']), "sid='{$session->sid}'");
            
            // Set login cookies
            my_setcookie('mybbuser', $user['uid'] . '_' . $user['loginkey'], null, true);
            my_setcookie('sid', $session->sid, -1, true);
            
        }

I would definitely just auth them on both mybb and flask whenever they log in on one (or disable logging on on mybb completely if you just want a little mini board on your site?) and just be sure their sessions/cookies all expire at the same time.
The IP address of where my site is hosted on PythonAnywhere changes so it wasn't the perfect solution unless I'm prepared to change the IP address everything in my remote access section.

I'm looking for someone to code a solution for this if possible