Accessing User object outside the CMS

Permalink
Hi,

I'm want to use the account system for an iPhone app, where users can login in this app via our account system so they don't have to re-register.

How I want to do it is make a login system like facebook, I include just a simple form, checking a php page, inside the same folder as concrete5, to check if the user exists. When is does, callback using a response like the username who is logged in.

I couldn't find any similar threads. Thanks!

peterwilli
 
Mnkras replied on at Permalink Reply
Mnkras
use a tool, it has the c5 environment, but none of the permissions or anything.
peterwilli replied on at Permalink Reply
peterwilli
A tool? I'm sorry if I sound a little unexperienced, this is the second time I touch concrete5 (and I love it!)
jordanlev replied on at Permalink Best Answer Reply
jordanlev
Create a php file in your site's top-level "tools" directory, and put your code there.

How exactly do you want this to work? Do you want the user to see a web page that has a login form and this login form is tied into the C5 site's user system? Or is this more of an API page that accepts an HTTP request from your app but users don't see the page itself? What about options for "I forgot my password" or "Register as new user"?

This thread might be helpful too -- I have some code in there for an all-in-one login and registration form via ajax:
http://www.concrete5.org/community/forums/themes/customizing-login-...

And here's another thread where someone customized the built-in reg/login page:
http://www.concrete5.org/community/forums/customizing_c5/i-am-re-co...

Nether of the above solutions I linked to utilize the "tools" though, but might help you figure out how to work with the built-in login/reg form code.
peterwilli replied on at Permalink Reply
peterwilli
Hi,

Thanks for the answer!
I solved it now, by creating a custom single page called api_login.php which is basically a exact copy of the original login.php

And I copied the controller login.php, to api_login.php

The api login is invisible, and I removed all of the form code, leaving an empty page, which is still accepting post request and checks login, and open the session and adds a string of the current username to it. I added a function to api_login.php which redirect to the $_GET parameter continue, so if you make a form, in either HTML or in other stuff (iPhone GUI) you can make a post request to the api_login, which then opens the session and I can use the username to check if a user is logged in!