Manol Posted February 25, 2016 Posted February 25, 2016 I would like to create a page that uses a template that returns some data, as "pages web service" but this template can be accessed only by certain role. Then a user must send credentials through ajax to get the data back , the http call comes from a phone, so the page trying to access the data is not on the server, is there a way to do it? I've search all around the forum but no way to get it working. Anybody has done something similar? How did you solve it? Thank you.
LostKobrakai Posted February 25, 2016 Posted February 25, 2016 A webservice is in no way different to a normal website besides the fact that it's returning different data, e.g. json instead of html. Build it like you normally would, but let the template output json. You just need to be aware, that the usage of sessions and session cookies, which power the authentication in processwire, are not the best option for webservice authentication.
Manol Posted February 26, 2016 Author Posted February 26, 2016 Is there any example on how to use sessions and session cookies with ajax and processwire? That would be really helpful!
qtguru Posted February 26, 2016 Posted February 26, 2016 I got hands on experience with Cordova however am curious you can't have CORS issues with Cordova, because that limitation doesn't affect cordova however check your <access> tag in the config.xml. Feel free to ask any question.
Manol Posted February 26, 2016 Author Posted February 26, 2016 Hi Sephiroth. I can get data back if the template that the page uses has a guest role. I don't have any problem with cordova when I use it with dreamfactory I can login retrieve data upload images... but because I like pw I would like to do the same with it but as mentioned before I'm not able to retrieve data from a page that uses a template with a role different to guest. The problem is my knowledge I suppose making calls through ajax to log to pw and get the data back.
Manol Posted February 26, 2016 Author Posted February 26, 2016 How can I check that the cookies in the header (ajax call) are the right ones in the actual session ( challenge, fingerprint ), what should I compare??
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now