1.3.2 Example

The following code is an exemple that uses the CookieAuthenticate module:

use CookieAuthenticate

CherryClass MemberArea(CookieAuthenticate):
mask:
    def index(self):
        <html><body>
        Welcome to the member area, <py-eval="self.login"><br>
        If you want to log out, just click <a py-attr="self.getPath()+'/doLogout'" href="">here</a>.<br>
        Otherwise, just click <a py-attr="request.base" href="">here</a> to go back to the home page.
        </body></html>
    def loginScreen(self, message, fromPage, login=''):
        <html><body>
            Welcome to the login page. Please enter your login and password below:
            <py-if="message==self.wrongLoginPasswordMessage">
                <br><font color=red>Sorry, the login or password was incorrect</font>
            </py-if>
            <form method="post" action="doLogin">
                Login: <input type=text name=login py-attr="login" value="" length=10><br>
                Password: <input type=password name=password length=10><br>
                <input type=hidden name=fromPage py-attr="fromPage" value=""><br>
                <input type=submit value="Login">
            </form>
        </body></html>
    def logoutScreen(self):
        <html><body>
            You have been logged out.<br>
            Click <a py-attr="request.base" href="">here</a> to go back to the home page.
        </body></html>
function:
    def getPasswordListForLogin(self, login):
        if login=="login": return ["password"]
        return []

CherryClass Root:
mask:
    def index(self):
        <html><body>
            Welcome to the site.<br>
            Click <a href='memberArea/index'>here</a> to access the
            member area.
        </body></html>

See About this document... for information on suggesting changes.