KonaKart Community Forum

Installation / Configuration => Programming of KonaKart => Topic started by: diegobuzzalino on January 16, 2010, 02:21:06 pm

Title: Does "getCustomerByUsername()" exists?
Post by: diegobuzzalino on January 16, 2010, 02:21:06 pm
I need something like this -> I need to gather some user information before the user logs in (user detected by cookies)

any ideas?

regards, Diego, from Argentina

(konakart rules!)
Title: Re: Does "getCustomerByUsername()" exists?
Post by: trevor on January 16, 2010, 02:34:16 pm
I don't understand fully what you need to do. The cart information is saved in a cookie so that an unregistered customer doesn't lose his cart contents. We have an API to save any other type of information in a similar fashion.
Title: Re: Does "getCustomerByUsername()" exists?
Post by: diegobuzzalino on January 16, 2010, 02:37:09 pm
First of all, thanks for the fast answer.

I'm working on "remember user and password" functionality.

So, I need to grab custom information from the database without logging in the user.
I guess that the "customerSearchIf" interface is the answer, but I can't find a factory/concrete class of this.
Title: Re: Does "getCustomerByUsername()" exists?
Post by: trevor on January 16, 2010, 02:44:53 pm
Does that mean that you want to automatically log in the user ?
Title: Re: Does "getCustomerByUsername()" exists?
Post by: diegobuzzalino on January 16, 2010, 02:51:13 pm
I don't want to work on "automatic login", because I'm not an Konakart-expert. I'd prefer not to change the login functionality.

I'd rather prefer to auto-complete the user and password fields on the Login Page, and then, continue with the standard flow, without any change.

(I know that this is not the most safe option, but for my business, it's safe enoufgh, and the cheaper option to implement.)

Currently, when the user log in, I store some information on the CustomX fields, and store a new cookie the user email.
That's working.

Now, I was working on "LoginAction", to add the logic for reading the cookies and the information from the databse. Here is where I found that I need a "getCustomerByEmail" or something like that.

I hope that I have been clear enough.
Title: Re: Does "getCustomerByUsername()" exists?
Post by: trevor on January 16, 2010, 03:08:03 pm
So you want to read the customer information from the database in order to perform an auto-complete ?

We only store the password in a hashed format so there is no way of retrieving it in order to do this.
Title: Re: Does "getCustomerByUsername()" exists?
Post by: diegobuzzalino on January 16, 2010, 03:15:40 pm
Here is where I thought about my trade off:
  - I need this functionality
  - I do NOT need extreme security.

So, I'm storing the password twice:
  - the original from Konakart
  - an encrypted version with different algorithm in a Custom field (This algorithm is reversible)

So, I do have the information on the database to fill the log in fields.
The only thing that I'm willing to do, is to grab that information from the database and put on a LoginForm in LoginAction (I added that form to the action in the sturts-config.xml file)

(BTW, thanks a lot for  the attention.. I really apreciate it)
Title: Re: Does "getCustomerByUsername()" exists?
Post by: trevor on January 16, 2010, 03:28:19 pm
In the application engine we don't allow anyone to see customer details other than the logged in customer seeing his own details. Otherwise through the api, customers would be able to see the details of other customers which wouldn't be very good!

What you could do is to use the admin api to get the customer details of any customer. In this case you'd have to log into the admin engine using an administrator username and password.
Title: Re: Does "getCustomerByUsername()" exists?
Post by: diegobuzzalino on January 16, 2010, 03:35:30 pm
mmm..got it...

in the admin code I have just found the method that I have been looking for on the client side:
     public AdminCustomer getCustomerForEmail(String s)

Let me think how I could use that from the client side..
Title: Re: Does "getCustomerByUsername()" exists?
Post by: diegobuzzalino on January 16, 2010, 03:46:07 pm
I know that Martin Fowler would kill me, but I think that in 20 minutes, I will be creating a database connection on the action, and directly grabbing that info.
Title: Re: Does "getCustomerByUsername()" exists?
Post by: trevor on January 16, 2010, 10:13:43 pm
Maybe better to implement a custom API call.