solved Bridge Hook to JR data

PatriaCo
PatriaCo
@the-patria-company
7 years ago
349 posts
I am working on a bridge to WHMCS. They already have an internal function for POSTing data to create a new user when a current email match does not exist. I am just not sure how capture the data from my JR hosted instance. Here is the hook file that is triggered on every login attempt in my WHMCS:

<?php
add_hook('ClientLoginShare', 1, function($vars) {
    // Perform custom authentication logic here

    // User not found
    return false;

    // Login as existing WHMCS Client by Email Address
    return array(
        'email' => 'jr_user@my-site.com',
    );

    // Create a new client and login
    return array(
        'create' => true,
        'email' => 'jr_user@my-site.com',
        'companyname' => 'JR Username',
        'password' => 'xxxxxxxx',
    );
});


I am assuming that when create=>true, I need to authenticate into my JR hosted db, match the Email and pull the Username, Password. Then pass those variables into the return array (

however, my basic understanding of what I think needs to happen, does not yet translate into code. ;) Would someone have a minute or two to give me a hand? Much appreciated.

Thanks.


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3

updated by @the-patria-company: 06/24/17 06:42:24PM
michael
@michael
7 years ago
7,715 posts
not sure what WHMCS is, but why not just use oneall for both. is there anything that needs to be passed between the two systems.

--edit--
The user passwords are not stored in cleartext in the database, you can not retrieve them. When a user logs in their password is run through a system to get a hash, then that hash is checked against the hash stored in the database. So we can check if the password is correct, but not check what that password IS.
updated by @michael: 03/22/17 12:10:31AM
PatriaCo
PatriaCo
@the-patria-company
7 years ago
349 posts
Yes, I am creating a "provisioning module" since my WHMCS instance is managing all of our advanced billing, live support and support tickets. I need to get the two systems talking. :)


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3
michael
@michael
7 years ago
7,715 posts
on the jamroom side of things, the only time the clear text password comes in is during signup form submission or user password update.

If you need it in cleartext then you'd have to listen for those events.
PatriaCo
PatriaCo
@the-patria-company
7 years ago
349 posts
Thanks for helping me think this through Michael.

WHMCS offers an account creation API, as well as WHMCS OpenID.

So if I were to create a module that listened for the clear text and sent it via the API over to WHMCS to create the account. Then turned on the OpenID through OneAll.

Could I then use the WHMCS OpenID for an admin account, to manage the profile's quota selection? Or is external access to OneAll credentials in Jamroom not accessible?


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3

updated by @the-patria-company: 03/22/17 07:44:03PM
michael
@michael
7 years ago
7,715 posts
where are they signing up to first? WHMS (whatever that is) or to Jamroom. If its WHMS then if you can get it to send over the username/password when a user signs up to it, you could create that jamroom user then in the same way the jrUser module creates users and also the jrOneAll module creates users. grab the user creation system from either of those two modules. or call whichver functions from those modules need calling.

(make sure to add a 'required' => 'jrUser' text to your modules _meta() function )

Then do the same when they sign in to your WHMS. (That covers LOGIN and SIGNUP).


--
Cant see any reason for the WHMS to access your database directly. Might be a case for Proxima... not sure

PROJECT: "Proxima: Mobile Backend as a Service"
https://www.jamroom.net/proxima

anyhow, you could get/put any info you wanted through a RESTful system.
updated by @michael: 03/23/17 01:08:16AM
PatriaCo
PatriaCo
@the-patria-company
7 years ago
349 posts
I have definitely been testing out Proxima. I cannot seem to access my api data via a HTTP Basic Authentication. I think it may have something to do with my system not registering as being a mobile device. Not for sure on this?

Currently all new signups are made on JR first (free account), then users are redirected to our WHMCS billing system when they want to upgrade.

Ultimately, I just need to be able to have our WHMCS billing system access a master admin account, find a user's profile and select the appropriate Quota.


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3
michael
@michael
7 years ago
7,715 posts
PatriaCo:....Currently all new signups are made on JR first (free account)....

Then you want to build a module that listens for the signup event and when that event fires, send out a
jrCore_load_url("http://whatever-url-you-want.com")

to fire off the creation system. You can send POST requests via that function, check it out.

Tags