source: cows_wps/trunk/cows_wps/controllers/login.py @ 6947

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows_wps/trunk/cows_wps/controllers/login.py@6947
Revision 6947, 1.6 KB checked in by astephen, 10 years ago (diff)

lots of minor fixes. including removing username from process configs.

Line 
1import logging
2
3from pylons import request, response, session, tmpl_context as c
4from pylons.controllers.util import abort, redirect_to
5
6from cows_wps.renderer.ui_renderer import *
7from cows_wps.controllers import *
8from cows_wps.lib.ui.proc_config import *
9
10log = logging.getLogger(__name__)
11
12
13class LoginController(BaseController):
14
15    def index(self):
16        redirect_to("/home.html")
17
18    def indexOLD(self):
19        """
20        Show login page.
21        """
22        login_form = """        <form action="/login/check" onSubmit="return validateTextInput(document.getElementById('username').value, /^[a-zz0-9A-Z]{4,20}$/, 'The username must be between 4 and 20 letters and/or numbers.');" >
23                <p>Please enter your details</p>
24                <label class="text_width_150"><b>Username: </b></label>
25                <input type="text" name="username" id="username" value="" size="20" /><br />
26                <label class="text_width_150"><b>Password: </b></label>
27                <input type="password" name="password" value="" size="20" />&nbsp;&nbsp;
28                <input type="submit" value="Login" />
29        </form>
30        """
31        renderer = UIPageRenderer()
32        resp = renderer.render("Login page", 
33                               [("Please log in", login_form)])
34        return resp
35       
36    def check(self):
37        """
38        Checks login.
39        """
40        username = request.params.get("username", None)
41        if username == None:
42            return "Please provide an argument username=&lt;Something&gt;" 
43
44        renderer = UIPageRenderer()
45        resp = renderer.render("Login page",
46                              [("Status: logged in", "You are logged in as: %s" % username)])
47        return resp
Note: See TracBrowser for help on using the repository browser.