Skip Menu |

This queue is for tickets about the Net-SugarCRM CPAN distribution.

Report information
The Basics
Id: 112080
Status: resolved
Priority: 0/
Queue: Net-SugarCRM

People
Owner: Nobody in particular
Requestors: joelgomezb [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Random Loggin Successfull
Date: Tue, 16 Feb 2016 08:55:11 -0430
To: bug-net-sugarcrm [...] rt.cpan.org
From: Joel Gómez <joelgomezb [...] gmail.com>
Hi Again, I tried this code: use Net::SugarCRM; use Data::Dumper; package Test; use Crypt::Digest::MD5 qw( :all ); our $login='admin'; our $pass=md5_hex('admin'); our $url='http://localhost/SugarCE/service/v4_1/rest.php'; package MyPackage; my $s = Net::SugarCRM->new(url=>$Test::url, restuser=>$Test::login, restpasswd=> $Test::pass ); print Dumper($s); And perfect login but i run it again (2, 3, 4 consecutives times) launch this error: $VAR1 = '{"application":"net_sugarcrm","user_auth":{"password":"21232f297a57a5a743894a0e4a801fc3","user_name":"admin"}}'; 2016/02/16 08:47:15 Error getting id <200 OK> fetching $VAR1 = '{"name":"Invalid Login","number":10,"description":"Login attempt failed please check the username and password"}'; 2016/02/16 08:47:15 at /home/joelgomezb/perl5/lib/perl5/Net/SugarCRM.pm line 356. 2016/02/16 08:47:15 Net::SugarCRM::_rest_request(Net::SugarCRM=HASH(0x2b41ad8), "login", "{\"application\":\"net_sugarcrm\",\"user_auth\":{\"password\":\"21232f"...) called at /home/joelgomezb/perl5/lib/perl5/Net/SugarCRM.pm line 418 2016/02/16 08:47:15 Net::SugarCRM::login(Net::SugarCRM=HASH(0x2b41ad8)) called at /home/joelgomezb/perl5/lib/perl5/Net/SugarCRM.pm line 314 2016/02/16 08:47:15 Net::SugarCRM::sessionid(Net::SugarCRM=HASH(0x2b41ad8)) called at /home/joelgomezb/perl5/lib/perl5/Net/SugarCRM.pm line 586 2016/02/16 08:47:15 Net::SugarCRM::get_module_entries(Net::SugarCRM=HASH(0x2b41ad8), "Cases", "") called at SugarCRM2.pl line 14 Error getting id <200 OK> fetching $VAR1 = '{"name":"Invalid Login","number":10,"description":"Login attempt failed please check the username and password"}'; at /home/joelgomezb/perl5/lib/perl5/Net/SugarCRM.pm line 356. Net::SugarCRM::_rest_request(Net::SugarCRM=HASH(0x2b41ad8), "login", "{\"application\":\"net_sugarcrm\",\"user_auth\":{\"password\":\"21232f"...) called at /home/joelgomezb/perl5/lib/perl5/Net/SugarCRM.pm line 418 Net::SugarCRM::login(Net::SugarCRM=HASH(0x2b41ad8)) called at /home/joelgomezb/perl5/lib/perl5/Net/SugarCRM.pm line 314 Net::SugarCRM::sessionid(Net::SugarCRM=HASH(0x2b41ad8)) called at /home/joelgomezb/perl5/lib/perl5/Net/SugarCRM.pm line 586 Net::SugarCRM::get_module_entries(Net::SugarCRM=HASH(0x2b41ad8), "Cases", "") calle Very random when it's login o not!!! any suggestions?? THX.. -- www.joelgomez.org.ve Linux User #435411
I agree, very weird, have you put SugarCRM in debug mode and checked the sugarcrm logs? Are you using any kind of external authentication in Sugar, like LDAP or AD? (not that I think this is relevant). Another try could be to properly logout (although that should be invoked in the DESTROY method by default). my $s = Net::SugarCRM->new(url=>$Test::url, restuser=>$Test::login, restpasswd=> $Test::pass ); $s->logout;
RT-Send-CC: joelgomezb [...] gmail.com
It has been a big headache to me during last days. The problem seems to be the random order of the perl HASH attributes because when the hash is retrieved by the SugarCMS API REST (which is PHP), is converted into an associative array and used with the function call_user_func_array: File: sugarcrm/service/core/REST/SugarRestJSON.php line 88 $res = call_user_func_array(array( $this->implementation, $method), $data); The second parameter of this function is an array of the parameters of the method indicated on the first parameter. So the order of the array parameters matters. In particular, in the login function, $data has two attributes looking like: { "application": "net_sugarcrm", "user_auth": { "user_name": "name", "password":"pass" } } If the application attribute goes first, login will fail because the method login will be invoked with string "net_sugarcrm" instead credentials array and viceversa. I attached a possible solution to this message using module "Tie::IxHash" to define the hashes that will be sent to the SugarCRM API. It affects to a dozen of calls. Best regards El Mié feb 17 02:16:32 2016, NITO escribió: Show quoted text
> I agree, > > very weird, > > have you put SugarCRM in debug mode and checked the sugarcrm logs? > > Are you using any kind of external authentication in Sugar, like LDAP > or AD? (not that I think this is relevant). > > Another try could be to properly logout (although that should be > invoked in the DESTROY method by default). > > my $s = Net::SugarCRM->new(url=>$Test::url, restuser=>$Test::login, > restpasswd=> $Test::pass > ); > > $s->logout;
Subject: SugarCRM.pm

Message body is not shown because it is too large.

Line 608 where says: $query =~ s/"/\\"/xg; must be deleted to avoid bad escape error El Jue Ago 02 10:19:08 2018, zarzuelo@gmail.com escribió: Show quoted text
> It has been a big headache to me during last days. > > The problem seems to be the random order of the perl HASH attributes > because when the hash is retrieved by the SugarCMS API REST (which is > PHP), is converted into an associative array and used with the > function call_user_func_array: > > File: sugarcrm/service/core/REST/SugarRestJSON.php line 88 > > $res = call_user_func_array(array( $this->implementation, $method), > $data); > > The second parameter of this function is an array of the parameters of > the method indicated on the first parameter. So the order of the array > parameters matters. > > In particular, in the login function, $data has two attributes looking > like: > > { > "application": "net_sugarcrm", > "user_auth": { > "user_name": "name", > "password":"pass" > } > } > > If the application attribute goes first, login will fail because the > method login will be invoked with string "net_sugarcrm" instead > credentials array and viceversa. > > I attached a possible solution to this message using module > "Tie::IxHash" to define the hashes that will be sent to the SugarCRM > API. It affects to a dozen of calls. > > Best regards > > El Mié feb 17 02:16:32 2016, NITO escribió:
> > I agree, > > > > very weird, > > > > have you put SugarCRM in debug mode and checked the sugarcrm logs? > > > > Are you using any kind of external authentication in Sugar, like LDAP > > or AD? (not that I think this is relevant). > > > > Another try could be to properly logout (although that should be > > invoked in the DESTROY method by default). > > > > my $s = Net::SugarCRM->new(url=>$Test::url, restuser=>$Test::login, > > restpasswd=> $Test::pass > > ); > > > > $s->logout;
Changes integrated in version 3.31000
Resolved in version 3.31000