Jump to content

Archived

This topic is now archived and is closed to further replies.

carlosmoreeira

CakePHP Basic Auth popup

Recommended Posts

Hello,

 

I have been using cakePHP now for a couple projects now. My next projects involves creating a web service and the entire front-end be built in angularjs. 

 

Now, I understand how 'Form' Authentication works, and have done some research and people tell me if I have an SSL to use Basic Auth, for a web service, which is what I am using. But I am having a problem hooking both up nicely. Now with angular, I have a call for a page and send over the username and password. If the credentials are correct, the server returns back the correct data. The problem is if the credentials are wrong, I get the normal 'Basic Auth' pop up, asking me for my username and password. 

 

My question is, instead of the server trying to re access the same page, is there a way to return json data back?

 

 

Example : I have an angular call going to 'cakerest/projects.json' -> Credentials are ok -> Data is returned, and with javascript I console.log it and see it.

 

2nd time I send the incorrect user and password, and the server responds back with a popup asking for credentials.

 

How can I get rid of that popup and just return "{Error : 'Credential problem'};

 

I can post code if that would help as well. 

 

Thank you

 

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.