summaryrefslogtreecommitdiff
path: root/demos/quickstart
diff options
context:
space:
mode:
Diffstat (limited to 'demos/quickstart')
-rw-r--r--demos/quickstart/protected/pages/Advanced/Auth.page42
-rw-r--r--demos/quickstart/protected/pages/GettingStarted/NewFeatures.page1
2 files changed, 43 insertions, 0 deletions
diff --git a/demos/quickstart/protected/pages/Advanced/Auth.page b/demos/quickstart/protected/pages/Advanced/Auth.page
index 531b8bdf..e0cbcaef 100644
--- a/demos/quickstart/protected/pages/Advanced/Auth.page
+++ b/demos/quickstart/protected/pages/Advanced/Auth.page
@@ -124,5 +124,47 @@ In the above, <tt>UserClass</tt> specifies what class will be used to create use
<p id="720566" class="block-content">
The user class has to implement the two abstract methods in <tt>TDbUser</tt>: <tt>validateUser()</tt> and <tt>createUser()</tt>. Since user account information is stored in a database, the user class may make use of its <tt>DbConnection</tt> property to reach the database.
</p>
+<com:SinceVersion Version="3.1.1" />
+<p id="720567" class="block-content">
+Since 3.1.1, <tt>TAuthManager</tt> provides support to allow remembering login. Accordingly, <tt>TDbUser</tt> adds two methods to facilitate the implementation of this feature. In particular, two new methods are introduced: <tt>createUserFromCookie()</tt> and <tt>saveUserToCookie()</tt>. Developers should implement these two methods if remembering login is needed. Below is a sample implementation:
+</p>
+<com:TTextHighlighter Language="php" CssClass="source block-content" id="code5">
+public function createUserFromCookie($cookie)
+{
+ if(($data=$cookie->Value)!=='')
+ {
+ $application=Prado::getApplication();
+ if(($data=$application->SecurityManager->validateData($data))!==false)
+ {
+ $data=unserialize($data);
+ if(is_array($data) && count($data)===3)
+ {
+ list($username,$address,$token)=$data;
+ $sql='SELECT passcode FROM user WHERE LOWER(username)=:username';
+ $command=$this->DbConnection->createCommand($sql);
+ $command->bindValue(':username',strtolower($username));
+ if($token===$command->queryScalar() && $token!==false && $address=$application->Request->UserHostAddress)
+ return $this->createUser($username);
+ }
+ }
+ }
+ return null;
+}
+
+public function saveUserToCookie($cookie)
+{
+ $application=Prado::getApplication();
+ $username=strtolower($this->Name);
+ $address=$application->Request->UserHostAddress;
+ $sql='SELECT passcode FROM user WHERE LOWER(username)=:username';
+ $command=$this->DbConnection->createCommand($sql);
+ $command->bindValue(':username',strtolower($username));
+ $token=$command->queryScalar();
+ $data=array($username,$address,$token);
+ $data=serialize($data);
+ $data=$application->SecurityManager->hashData($data);
+ $cookie->setValue($data);
+}
+</com:TTextHighlighter>
<div class="last-modified">$Id$</div></com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page b/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page
index adc19fc7..faf3b9b1 100644
--- a/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page
+++ b/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page
@@ -17,6 +17,7 @@ This page summarizes the main new features that are introduced in each PRADO rel
<li>Added support to TDataGrid to allow grouping consecutive cells with the same content.</li>
<li>Added support to allow configuring page properties and authorization rules using <a href="?page=Configurations.PageConfig">relative page paths</a> in application and page configurations. Added support to allow <a href="?page=Advanced.Auth">authorization</a> based on remote host address.</li>
<li>Added a new page state persister <tt>TCachePageStatePersister</tt>. It allows page state to be stored using a cache module (e.g. TMemCache, TDbCache, etc.)
+<li>Added support to the <a href="?page=Advanced.Auth">auth framework</a> to allow remembering login.</li>
</ul>
<h2 id="8006">Version 3.1.0</h2>