Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Using Vanilla logged in cookie to enable access for mini app inside the same domain/server
cvllos
New
Hi guys,
I have a topic where we manage a follow up list with specific user's data. I would like to create a small app with PHP in a different web folder to let each user add, update and delete his own data. It will be an easy app and I would like the app (CRUD) to use Vanilla's logged in cookie and autentication to enable user maintenance and limit user modification to his own data only. I intend also to, later, create a CRON script to publish data to the topic once per day.
Is there a way to use Vanillas authentication cookie(s) and session status to check login status and also retrieve user login Id ?
The part related to publishing data into a topic I guess I should use the API V2 to do that + CRON jobs. right ?
thanks in advance
0
Comments
Here is a small "Hello User" (you have to change the PATH_ROOT definition to your needs):
Better Impossible.
Worked like a charm !
@R_J ,Thank you very much !
Abusing from you help, how to detect if logged in user is already confirmed (not still an "unconfirmed" user) or if the user is an Admin or Moderator ?
thanks in advance (*again*)
best regards,
Sorry... I think I didn't mention one important info. My current Vanilla version is 2.6.4
Best,
This is how the GDN_User table is defined:
Gdn::session()->User is an object which has all those table columns as properties. Therefore you can simply check for the value of Gdn::session()->User->Confirmed
To get the roles a user has, you need to make use of the UserModel: `$userModel = new UserModel();`. But the class.gdn.php also lets you access the UserModel. In order to find out more about the roles, you should look at the RoleModel
Then you can extract the roles with array_column($userRoles, 'RoleID') and see if there is an intersection between those two RoleID arrays
@R_J , I think it's enough to go deeper by myself
Thanks a lot for the explanation !
Best,