simple auth check for custom plugin

Can anyone give me an example snip of the code I can put in my header to make sure the user is authenticated before running the php code?

Much Appreciated!

Hi,

If you’re creating a page that you want to run when a user is logged in it’s probably simpler to create an entry point and use this. See this page http://support.sugarcrm.com/02_Documentation/04_Sugar_Developer/Sugar_Developer_Guide_6.7/02_Application_Framework/Entry_Points/02_Creating_Custom_Entry_Points/

If you need this to be separate from SuiteCRM for some reason then you’ll need to check the current user using the authenticated_user_id session variable. Ideally you would use the AuthenticationController to check the user is legitimate but this may require pulling in extra entry point code. See the loadUser method in include/MVC/SugarApplication.php for how SuiteCRM handles the auth check.

Thanks,
Jim

1 Like

Perfect, thanks!