DokuWiki

It's better when it's simple

User Tools

Site Tools


devel:working_example_of_trustexternal

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
devel:working_example_of_trustexternal [2012-11-14 19:23]
24.18.245.38 created
devel:working_example_of_trustexternal [2018-08-01 12:14] (current)
java4life Bugfix
Line 1: Line 1:
 +====== Working Example of trustExternal() ======
 +
 +
 After spending way too much time trying to make this work, I finally figured it out. Here are the details you need to know that the docs don't tell you: After spending way too much time trying to make this work, I finally figured it out. Here are the details you need to know that the docs don't tell you:
   - The trustExternal method will be called on every page load. However, the $user and $pass parameters are only present when the user first logs in. On all subsequent page loads, they will be empty. ​   - The trustExternal method will be called on every page load. However, the $user and $pass parameters are only present when the user first logs in. On all subsequent page loads, they will be empty. ​
   - You must fill in the $USERINFO array on every page load   - You must fill in the $USERINFO array on every page load
  
-So my solution is to first check the $_SESSION for the previous login. If found, fill the $USERINFO array and return true. Only if this is not found, do we go the database to look for a login.\\ +So my solution is to first check the $_SESSION for the previous login. If found, fill the $USERINFO array and return true. Only if this is not found, do we go the database to look for a login. 
-Here is my complete solution. This example checks a mongodb database, but you should be able to easily change this to use any other datastore.\\ + 
-\\+Here is my complete solution. This example checks a mongodb database, but you should be able to easily change this to use any other datastore.
  
-''​+<code php auth_mongodb.class.php>​
 class auth_mongodb extends auth_basic { class auth_mongodb extends auth_basic {
  
Line 31: Line 34:
  
  if (!empty($_SESSION[DOKU_COOKIE]['​auth'​]['​info'​])) {  if (!empty($_SESSION[DOKU_COOKIE]['​auth'​]['​info'​])) {
- $USERINFO['​name'​] = $_SESSION[DOKU_COOKIE]['​auth'​]['​info'​]['​user'];+ $USERINFO['​name'​] = $_SESSION[DOKU_COOKIE]['​auth'​]['​info'​]['​name'];
  $USERINFO['​mail'​] = $_SESSION[DOKU_COOKIE]['​auth'​]['​info'​]['​mail'​];​  $USERINFO['​mail'​] = $_SESSION[DOKU_COOKIE]['​auth'​]['​info'​]['​mail'​];​
  $USERINFO['​grps'​] = $_SESSION[DOKU_COOKIE]['​auth'​]['​info'​]['​grps'​];​  $USERINFO['​grps'​] = $_SESSION[DOKU_COOKIE]['​auth'​]['​info'​]['​grps'​];​
Line 65: Line 68:
  }  }
 } }
-''​+</​code>​
devel/working_example_of_trustexternal.1352917432.txt.gz · Last modified: 2012-11-14 19:23 by 24.18.245.38