solved Proxima Login fail

nate
@nate
9 years ago
917 posts
Quote:
I/PaymentActivity﹕ http://n8flex.com/api/user/login?id=16&password=123456
I/PaymentActivity﹕ {"code":400,"text":"Bad Request","note":"invalid password or id"}

It's telling me I have a bad password or ID. Both are correct.
updated by @nate: 03/11/15 08:08:12AM
brian
@brian
9 years ago
10,148 posts
I see the problem - let me fix it and push a new version out real quick.

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
brian
@brian
9 years ago
10,148 posts
I've just pushed version 1.0.1 of Proxima User - update to that and it should work for you now. I also moved this post over to the Proxima forum - if you could make sure all Proxima related posts are posted in here that would be great.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
Will do. Thanks.
nate
@nate
9 years ago
917 posts
Now it's back to saying invalid module.
nate
@nate
9 years ago
917 posts
Oh my bad. It's inactive.
nate
@nate
9 years ago
917 posts
Ok so when I log in I am doing this as the Authentication

String credentials = ClientMap.PROXIMA_PASSWORD + ":" + ClientMap.PROXIMA_PASSWORD;

This works when logging in. Then I do this to post a payment

String credentials = ClientMap.PROXIMA_PASSWORD + ":" + session_id;

And on the server side I am only debugging the user

fdebug($_user);

And I get this in the debug log.

Quote: (2015-01-21T18:42:48+00:00.0.85112300 : 0)-(mem: 9437184)-(pid: 651868)-(ip: 97.85.164.92)-(uri: n8flex.com/msone/checkout/token=tok_15NTRCEVo3ItZB1yHeR5qRHu/total=220/last4=4242/ids=28) Array ( [quota_id] => 0 [user_language] => en-US [is_logged_in] => no )
brian
@brian
9 years ago
10,148 posts
What are you mapping to PROXIMA_PASSWORD?


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
The client key.
nate
@nate
9 years ago
917 posts
I just double checked the session ID. It is correct.
nate
@nate
9 years ago
917 posts
I am posting the payment to my own module.
brian
@brian
9 years ago
10,148 posts
Natedogg265:
I am posting the payment to my own module.

They I have no idea how you are handling that.... did you create a Proxima module?


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
No. my module integrates Stripe to handle payments. I asked if this was allowed a few weeks ago.

function view_n8MSOne_checkout($_post, $_user, $_conf) {
	
	if (!jrUser_is_logged_in()) {
		$_re['msg'] = "user must be logged in";
		fdebug($_user);
		return n8MSOne_response($_re);
	}
	
	// validate post
	$_data = n8MSOne_validate($_post);	
	
	$file = APP_DIR . "/modules/n8MSOne/lib/Stripe.php";
	if (!is_file($file)) {
		jrCore_logger('CRI', "unable to load stripe library");
		$_re['msg'] = "Missing Stripe library";
		return n8MSOne_response($_re);
	}
	require_once $file;
	if ( strlen("{$_conf['n8MSOne_stripe_key']}") == 0) {
		jrCore_logger('CRI', "Stripe API key not set");
		$_re['msg'] = "System error";
		return n8MSOne_response($_re);
	}
	Stripe::setApiKey("{$_conf['n8MSOne_stripe_key']}");	
	
	// Create the charge on Stripe's servers - this will charge the user's card
	try {
		$charge = Stripe_Charge::create(array(
				"amount" 	=> $_data['total'],
				"card" 		=> $_data['token'],
				"description" 	=> $_data['email'],
				"currency" 	=> "usd"
			)
		);		
	} catch(Stripe_CardError $e) {
		$_re['msg'] = $e;		
		return n8MSOne_response($_re); 
	}

	// Create transaction record
	//$_data = n8MSOne_create_txn($_data, $charge);
		
	// Create puchases record for user
	//$_data = n8MSOne_create_purchases($_data);
	
	// Create sales record for seller
	//$_rs = n8MSOne_create_sales($_data);
	
	fdebug($_user);
	
	$_rs['type'] = "success";
	$_rs['msg'] = $_user['user_id'];
	
	// respond to app	
	return n8MSOne_response($_rs); 
}
nate
@nate
9 years ago
917 posts
N8: I did look at Proxima and meant to mention it in my question. Can I use it solely for authentication? I need to use my own module for building lists and transactions. Does it have docs?
updated by @n8flex: 02 Jan 2015 02:37:16PM - See more at: https://www.jamroom.net/the-jamroom-network/forum/jamroom-developers/20254/jamroom-new-user#last

Brian: Yep - you can use it for authentication. Here's a guide to the user service: - See more at: https://www.jamroom.net/the-jamroom-network/forum/jamroom-developers/20254/jamroom-new-user#last

I can see how this wasn't clear.
updated by @nate: 01/21/15 11:48:52AM
nate
@nate
9 years ago
917 posts
So do I even need to use proxima? Have I wasted 2 days? A user account does me little good if I cant post as logged in.
updated by @nate: 01/21/15 12:11:33PM
nate
@nate
9 years ago
917 posts
I'll use proxima to create the user account and do my own log in.
updated by @nate: 01/21/15 12:18:48PM
brian
@brian
9 years ago
10,148 posts
Natedogg265:
So do I even need to use proxima? Have I wasted 2 days? A user account does me little good if I cant post as logged in.

Proxima will help you with login and authentication, so yes - it would be helpful. However, if you want to use Proxima authentication then you need to build your module as a "proxima" module - not a "regular" Jamroom module.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
Does that mean I need to build the module inside the ACP?
brian
@brian
9 years ago
10,148 posts
Natedogg265:
Does that mean I need to build the module inside the ACP?

No - it just means you need to create (up to) 4 functions in your include.php file that are associated with POST/GET/PUT/DELETE - i.e.

/**
 * n8MSOne module POST Method functions
 * @param $_post array jrProximaCore post|get|put|delete URL vars
 * @param $_app array Proxima Application
 * @param $_cfg array jrProximaUser module config
 * @param $_vars array Method parameters
 * @return string
 */
function n8MSOne_px_method_post($_post, $_app, $_cfg, $_vars)
{ // This is your modules POST method - run your code when you receive a post request $_rs = array( 'return_key' => 'return_val' ); return jrProximaCore_http_response(200, 'OK', $_rs); }

Proxima watches for view functions with "px_method" in them and knows it is a Proxima module. So you would call it AFTER "api" using the name you gave it in the init - i.e. if your module_url in init was "n8msone" you would change it to "px_n8msone" and then access your module at:

http://yoursite.com/api/n8msone"

using POST/GET/PUT/DELETE

Check out the jrProximaData/include.php file for a good example of how it should be set up.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
After looking at everything, I basically just need to change my checkout function to a proxima post or put and make the changes to the include file to be a proxima module. All my other lists can stay the same.

Thanks.
nate
@nate
9 years ago
917 posts
Wait, I don't see the user array.
brian
@brian
9 years ago
10,148 posts
Natedogg265:
Wait, I don't see the user array.

Unlike "normal" Jamroom view functions, the $_user array is not automatically populated for you - if you want to get the "active" user's info you would do:

$user_id = jrProximaCore_get_session_user_id();
$_user   = jrCore_db_get_item('jrUser', $user_id);

Then $_user would contain the user info.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
You have a typo in the update section of the proxima docs. apu

brian
@brian
9 years ago
10,148 posts
Thanks - I have that fixed up.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
I can create an account and update the user account. I did have trouble in one area of log in.

I would log in and as soon and the return came back from the server I would immediately post a payment. Proxima would never recognize the new session. The old session would still work. I thought well maybe I am doing it too soon and the server wasn't yet finished. But I kinda doubt that.
brian
@brian
9 years ago
10,148 posts
Natedogg265:
I can create an account and update the user account. I did have trouble in one area of log in.

I would log in and as soon and the return came back from the server I would immediately post a payment. Proxima would never recognize the new session. The old session would still work. I thought well maybe I am doing it too soon and the server wasn't yet finished. But I kinda doubt that.

Yeah that should be immediately updated - it's not an "eventual thing". When you login and get that session_id in the return JSON, that means it is setup in the DB - when you try to use that immediately, what is the actual error you are getting?

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
Well when I try the login and try to post a payment proxima is not recognizing the session. Invalid session is what I get.
brian
@brian
9 years ago
10,148 posts
Natedogg265:
Well when I try the login and try to post a payment proxima is not recognizing the session. Invalid session is what I get.

Let me see the actual JSON you get back - that way I know where in the code it is coming from. Also - what URL are you calling when you get it, and are you sure you're updating your REST request to use the new session_id as the password?


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
I/PaymentActivity﹕ http://n8flex.com/api/user/login?id=26&password=123456
I/PaymentActivity﹕ {"code":200,"text":"OK","note":"session started","data":{"session_id":"2a139cf4aab1396c4cc179cf550d9490"}}
I/PaymentActivity﹕ http://n8flex.com/api/msone/checkout/tok_15OtXoEVo3ItZB1yyudGr3Os/220/4242/27
I/PaymentActivity﹕ session id to payment is 2a139cf4aab1396c4cc179cf550d9490
I/PaymentActivity﹕ {"code":401,"text":"Unauthorized","note":"invalid user session"}
brian
@brian
9 years ago
10,148 posts
OK thanks for that - that's helpful. Are you using Memcache or MySQL as your proxima caching layer?

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
MySQL.
brian
@brian
9 years ago
10,148 posts
Yeah that should be working - let me check it out.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
Any word on this?
brian
@brian
9 years ago
10,148 posts
Natedogg265:
Any word on this?

I've just pushed new versions of ProximaCore, ProximaUser and ProximaCache that I believe will fix this up. Update and let me know if you still see an issue.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
Thanks, B.
nate
@nate
9 years ago
917 posts
Quote: I/PaymentActivity﹕ http://n8flex.com/api/user/login?id=26&password=123456
I/PaymentActivity﹕ {"code":200,"text":"OK","note":"session started","data":{"session_id":"daa20160466c08aae6b608c6a6eaa14c"}}
I/PaymentActivity﹕ http://n8flex.com/api/msone/checkout/tok_15R8UfEVo3ItZB1y6XOoYG5s/988/4242/27,23,29,6
I/PaymentActivity﹕ session id to payment is daa20160466c08aae6b608c6a6eaa14c
I/PaymentActivity﹕ {"code":401,"text":"Unauthorized","note":"invalid user session"}

No changes for me using 1.0.2.
updated by @nate: 01/31/15 01:13:59PM
brian
@brian
9 years ago
10,148 posts
I have Unit tests in place for this exact scenario and they work, so something else is going on here.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
OK.
brian
@brian
9 years ago
10,148 posts
Just to be sure after the login, you are then using the app_id + session_id as the Basic Authentication?


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
[code]
public static String postData(URI uri, String session_id){
AndroidHttpClient client = AndroidHttpClient.newInstance("AndroidAgent");
HttpPost request = new HttpPost(uri);
String credentials = ClientMap.PROXIMA_PASSWORD + ":" + session_id;
String base64EncodedCredentials = Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
request.addHeader("Authorization", "Basic " + base64EncodedCredentials);
HttpResponse response;

Log.i(TAG, "session id to payment is " +session_id);

try {
response = client.execute(request);
return EntityUtils.toString(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
client.close();
}

}
{/code]

Quote:
I/PaymentActivity﹕ <a href="http://n8flex.com/api/user/login?id=26&password=123456" target="_blank" rel="nofollow">http://n8flex.com/api/user/login?id=26&password=123456</a>
I/PaymentActivity﹕ {"code":200,"text":"OK","note":"session started","data":{"session_id":"f4c7e8eb9ac182b66329b78d2c1a4747"}}

Quote:
I/httpManager﹕ session id to payment is f4c7e8eb9ac182b66329b78d2c1a4747
I/PaymentActivity﹕ {"code":401,"text":"Unauthorized","note":"invalid user session"}

I use this method in the putData to update the user info. Of course this is with my original session.
nate
@nate
9 years ago
917 posts
My issue is if I create an account and just use that session it all works.
nate
@nate
9 years ago
917 posts
App ID or client key?
updated by @nate: 01/31/15 01:39:45PM
brian
@brian
9 years ago
10,148 posts
Natedogg265:
My issue is if I create an account and just use that session it all works.

So in your above code I assume PROXIMA_PASSWORD is the app_id ? The session_id returned on login and create should be the same, so I'm not sure what is going on here. You updated to the latest module releases yesterday? (just double checking).

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
brian
@brian
9 years ago
10,148 posts
Natedogg265:
App ID or client key?

Sorry - I actually think it is the client key - not app_id (I'm not at my dev system right now).


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
It's the client key. Same I used in the putData. I updated this morning.
brian
@brian
9 years ago
10,148 posts
Natedogg265:
It's the client key. Same I used in the putData. I updated this morning.

OK - I can't do it now, but ZIP up your module and send it to me (if that is OK) so I can check it out. I don't think the problem is in your module, but hopefully it breaks for me on my local Proxima install and I can see what is going on.

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
Sent to 2 email addresses.
updated by @nate: 01/31/15 03:56:10PM
brian
@brian
9 years ago
10,148 posts
Natedogg265:
Sent to 2 email addresses.

Got it - I have had some issues recently with email (I use Rackspace hosted email) and they have been making changes to their spam detection, and it looks like it has gotten A LOT more aggressive, so if you've sent me something in the last couple weeks I may not have seen it, and I'm not seeing it in spam, so please resend to me and I will know it is coming.

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
I just sent it.
brian
@brian
9 years ago
10,148 posts
I just installed your module locally and it is working - no issues. I placed this:

return jrProximaCore_http_response(400, 'you got here');

right after:

//Create user
$user_id = jrProximaCore_get_session_user_id();
$_user   = jrCore_db_get_item('jrUser', $user_id);

in your post function, and I am hitting it, so something else is broken on your site. Make sure you do not have multiple modules with the same URL running.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
I'll do a fresh install and run the app from a permanent sub domain.
nate
@nate
9 years ago
917 posts
My confusion comes from when I create a new user a session is started. If I use that session everything works. It's when I create a new session by logging in that is stops working.
brian
@brian
9 years ago
10,148 posts
Natedogg265:
My confusion comes from when I create a new user a session is started. If I use that session everything works. It's when I create a new session by logging in that is stops working.

I understand - but that is working here for me with your module, so something else is up.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
When I test I get this. There are no other modules installed other than jr modules and the module we are testing.

Quote:
I/PaymentActivity﹕ http://n8flex.com/api/user/login?id=32&password=123456
I/PaymentActivity﹕ login response is {"code":200,"text":"OK","note":"session started","data":{"session_id":"07a37a7d95d36f9342a6c2db0aa7a9a2"}}

Posting payment

Quote:
I/PaymentActivity﹕ http://n8flex.com/api/msone/checkout/tok_15SWa9EVo3ItZB1yD88GlDgS/199/4242/29
I/PaymentActivity﹕ session id to payment is 07a37a7d95d36f9342a6c2db0aa7a9a2
I/PaymentActivity﹕ {"code":401,"text":"Unauthorized","note":"invalid user session"}

httpManger

Quote: I/httpManager﹕ session id to payment is 07a37a7d95d36f9342a6c2db0aa7a9a2

public static String postData(URI uri, String session_id){
        AndroidHttpClient client = AndroidHttpClient.newInstance("AndroidAgent");
        HttpPost request = new HttpPost(uri);
        String credentials = ClientMap.PROXIMA_PASSWORD + ":" + session_id;
        String base64EncodedCredentials = Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
        request.addHeader("Authorization", "Basic " + base64EncodedCredentials);
        HttpResponse response;

        Log.i(TAG, "session id to payment is " + session_id);

        try {
            response = client.execute(request);
            return EntityUtils.toString(response.getEntity());
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        } finally {
            client.close();
        }

    }

updated by @nate: 02/04/15 09:25:00AM
brian
@brian
9 years ago
10,148 posts
I can't replicate that here - I'm doing the exact same thing and I get to your POST function (where I debug and exit).

I would need to have access to your site to find out what the issue is.

support [at] jamroom [dot] net

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
I hate to ask you to log in, but this is my last step before I add SSL and publish.
brian
@brian
9 years ago
10,148 posts
Try this - modify your modules/N8MSone/include.php file and modify the top of your POST function so it looks like this:

function n8MSOne_px_method_post($_post, $_app, $_cfg, $_vars)
{ global $_conf; //Create user $user_id = jrProximaCore_get_session_user_id(); $_user = jrCore_db_get_item('jrUser', $user_id); return jrProximaCore_http_response(400, 'in post method');

Then run it and see if you get:

{ code: 400, text: 'Bad Request', note: 'in post method' }

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
No changes. I never make it this far. Proxima kicks back 401 before it ever makes it too my app.

Quote: {"code":401,"text":"Unauthorized","note":"invalid user session"}
brian
@brian
9 years ago
10,148 posts
Natedogg265:
No changes. I never make it this far. Proxima kicks back 401 before it ever makes it too my app.

Quote: {"code":401,"text":"Unauthorized","note":"invalid user session"}

I think your Android code is caching the session - I know you log this:

I/PaymentActivity﹕ session id to payment is 07a37a7d95d36f9342a6c2db0aa7a9a2

But are 100% positive that value is what is actually in the object and being used? Put some fdebug calls in to jrProximaCore/index.php file in the view_jrProximaCore_default() function and ensure the keys you are sending are valid.

I'm fairly positive this is working as I am doing the exact same thing as you but I am using NodeJS instead of Android and it is working.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
This is what's returned

Quote: I/PaymentActivity﹕ {"code":200,"text":"OK","note":"session started","data":{"session_id":"4476e810c631dece12aa398bd73f7b00"}}

This is what's in the jr_jrproximacore_session table
Quote: cd33784ce52dce710d28bc60056e657e
brian
@brian
9 years ago
10,148 posts
Yeah I guess something is messed up. I just have no way to test on your site for you - all I can tell you is that it is 100% working here for me - using YOUR code. The only difference you and I have is that I am running with NodeJS - not android.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

updated by @brian: 02/04/15 04:45:51PM
brian
@brian
9 years ago
10,148 posts
Here's the raw JSON output on my Proxima site using your script:

{ code: 200,
  text: 'OK',
  note: 'session started',
  data: { session_id: '014a44ad560481e881e26340f80eae84' } }
ok 14 jrProximaData tests Login User: with password should login user + session
{ code: 400, text: 'Bad Request', note: 'in post method' }
not ok 15 jrProximaData tests Create N8: testing should work?

So the first bit of JSON is for unit test #14 (login user and get session)

the "not ok 15" is your script where I am outputting what I had you output above - it's coming from your post function. The "not ok" means a 400 error was returned (which I am doing on purpose).

This is using the MySQL cache setup in Proxima.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
When I create a user I get a match

Quote: I/GCMMain﹕ {"code":201,"text":"Created","note":"user created and session started","data":{"_id":39,"session_id":"6ee36a4827fddc202b0cdb654cc023dc","location":"http:\/\/n8flex.com\/api\/user\/39"}}

Quote: 6ee36a4827fddc202b0cdb654cc023dc
nate
@nate
9 years ago
917 posts
So it's something on my server?
brian
@brian
9 years ago
10,148 posts
So that's user_id 39 - you're already logged in at that point. Are you trying to post to /login after that?


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
Yes, if the user goes to make a payment beyond 6 days the app logs in to have a valid session. For testing, I've changed it to 10 seconds.

I deleted all proxima sessions and these are the only 2 present. The first was a log in attempt by user 38.

Quote: I/PaymentActivity﹕ {"code":200,"text":"OK","note":"session started","data":{"session_id":"4476e810c631dece12aa398bd73f7b00"}}

recorded
Quote: cd33784ce52dce710d28bc60056e657e

On the second one, I created a new user, 39.

Quote: {"code":201,"text":"Created","note":"user created and session started","data":{"_id":39,"session_id":"6ee36a4827fddc202b0cdb654cc023dc","location":"http:\/\/n8flex.com\/api\/user\/39"}}

recorded
Quote: 6ee36a4827fddc202b0cdb654cc023dc

updated by @nate: 02/04/15 05:13:50PM
nate
@nate
9 years ago
917 posts
So that we're clear, the error is happening at log in, not at the payment post. The session returned does not match the session recorded.
brian
@brian
9 years ago
10,148 posts
That's pretty much exactly what I am doing - but I see the correct session:

{ code: 200,
  text: 'OK',
  note: 'session started',
  data: { session_id: '7714c16be32f733c2bed0969423b4888' } }

and in the DB:

7714c16be32f733c2bed0969423b4888	4	1355	1350	1423704546

When you log in and get that session_id, that is the value that is returned by the function that actually creates it - so for them to be different, I just have no idea why you would see that. Here's the function that creates the session key:

function plugin_jrProximaCore_mysql_create_user_session($app_id, $_user, $expires)
{ $exp = (time() + $expires); $key = md5(microtime() . jrCore_get_ip()); $tbl = jrCore_db_table_name('jrProximaCore', 'session'); $uid = (int) $_user['_user_id']; $pid = (int) $_user['_profile_id']; $req = "INSERT INTO {$tbl} (session_key, session_app_id, session_user_id, session_profile_id, session_expires) VALUES ('{$key}', '{$app_id}', '{$uid}', '{$pid}', '{$exp}') ON DUPLICATE KEY UPDATE session_expires = '{$exp}'"; if (jrCore_db_query($req)) { return $key; } return false; }

You can see it returns $key, which is the same value it inserts into the DB.

I wish I could tell you why you're seeing an issue on your system, but I just don't know.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
When I create a user, I get the same session_id returned as the session_key recorded. When I later try to log in as an existing user, the session_id returned does not match the session_key in the DB.

Are you saying somehow the data is being read wrong by my app? Only on log in and not when I create a user? I'm logging it as a raw string before I do anything to it. They use the same handler upon return.
nate
@nate
9 years ago
917 posts
Quote: cd33784ce52dce710d28bc60056e657e 2 38 39 1423702283

{"session_id":"4476e810c631dece12aa398bd73f7b00"}

Quote: 6ee36a4827fddc202b0cdb654cc023dc 2 39 40 1423702429

{"_id":39,"session_id":"6ee36a4827fddc202b0cdb654cc023dc","location":"http:\/\/n8flex.com\/api\/user\/39"}
nate
@nate
9 years ago
917 posts
I just did another log in, got back a session_id, checked the db and there is no session recorded.

I did this twice with no session recorded now.
updated by @nate: 02/04/15 06:53:14PM
nate
@nate
9 years ago
917 posts
Ok so what's going on is, if a user with an existing session logs in the session is not being recorded. If I delete all sessions, I can log in and everything works. I can try to set my expiration date to match yours. Is it 7 exact days?
nate
@nate
9 years ago
917 posts
Note. it's not being recorded but it is returning a session_id. As if it is being recorded.
nate
@nate
9 years ago
917 posts
It 0nly works sometimes.

{"code":200,"text":"OK","note":"session started","data":{"session_id":"70572eefa9709aa68ab0dd2b07b5a74c"}}

------------------------------

cc51c83f8affd1dd2fc022e54ea23d78 2 40 41 1423711072

Seems to work properly only when the table is empty.
updated by @nate: 02/04/15 07:20:18PM
brian
@brian
9 years ago
10,148 posts
Natedogg265:
Ok so what's going on is, if a user with an existing session logs in the session is not being recorded. If I delete all sessions, I can log in and everything works. I can try to set my expiration date to match yours. Is it 7 exact days?

So you're already logged in, but posting to /login again? Or are you signing up and then posting to /login? You shouldn't be doing either of those if that is the case. I'll have to follow up with you in the AM, but double check the order you're doing your signup/login.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
What it is doing is updating the existing session with a new expiration time. But it's returning a brand new session_id.
nate
@nate
9 years ago
917 posts
So, I sign up I get a session back I can use it fine.

When I log in later (as I will have to eventually), if the user has any session in the db (expired or not), it does not record a new session in the db. It only updates the existing session with a new expiration time, and returns a new session id to my app. I can ignore this new id but is that how it's suppose to work?



updated by @nate: 02/04/15 08:27:11PM
brian
@brian
9 years ago
10,148 posts
I just pushed up a new release of Proxima Core that should fix this - update and let me know if that finally works for you now. Thanks for hanging in there with me on this one - it was actually staring me "right in the face" but I couldn't see it since my unit tests don't re-use user accounts.

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
nate
@nate
9 years ago
917 posts
You hang in there for me all the time. I'm sure I owe you 100 more. lol

Thanks!!

Tags