summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2014-01-28 13:10:19 +0100
committerPetr Vobornik <pvoborni@redhat.com>2014-02-11 18:02:40 +0100
commita24c2378d9a6c7fa9a4333d029d8108aadf12487 (patch)
treeec147acb1d78ed3b5e2e769728649972c97f59ff
parent6a78923025fc852069c5e167736ad79cde0f940e (diff)
downloadipsilon-a24c2378d9a6c7fa9a4333d029d8108aadf12487.tar.gz
ipsilon-a24c2378d9a6c7fa9a4333d029d8108aadf12487.tar.xz
ipsilon-a24c2378d9a6c7fa9a4333d029d8108aadf12487.zip
PAM page
Signed-off-by: Petr Vobornik <pvoborni@redhat.com>
-rwxr-xr-xipsilon/login/authpam.py61
-rw-r--r--templates/login/pam.html77
2 files changed, 83 insertions, 55 deletions
diff --git a/ipsilon/login/authpam.py b/ipsilon/login/authpam.py
index d5ab428..496a774 100755
--- a/ipsilon/login/authpam.py
+++ b/ipsilon/login/authpam.py
@@ -38,37 +38,58 @@ class Pam(LoginPageBase):
return None
def GET(self, *args, **kwargs):
- return self._template('login/pam.html', title='Login',
- action='%s/login/pam' % self.basepath,
- service_name=self.lm.service_name,
- help_text=self.lm.help_text,
- username_text=self.lm.username_text,
- password_text=self.lm.password_text)
+ context = self.create_tmpl_context()
+ # pylint: disable=star-args
+ return self._template('login/pam.html', **context)
def POST(self, *args, **kwargs):
- username = None
- password = None
+ username = kwargs.get("login_name")
+ password = kwargs.get("login_password")
user = None
- for key, value in kwargs.iteritems():
- if key == 'login_name':
- username = value
- elif key == 'login_password':
- password = value
- if username is not None and password is not None:
- user = self._authenticate(username, password)
- else:
- cherrypy.log.error("Error: Username or password is missing")
+ error = None
- if user:
- return self.lm.auth_successful(user)
+ if username and password:
+ user = self._authenticate(username, password)
+ if user:
+ return self.lm.auth_successful(user)
+ else:
+ error = "Authentication failed"
+ cherrypy.log.error(error)
else:
- return self.lm.auth_failed()
+ error = "Username or password is missing"
+ cherrypy.log.error("Error: " + error)
+
+ context = self.create_tmpl_context(
+ username=username,
+ error=error,
+ error_password=not password,
+ error_username=not username
+ )
+ # pylint: disable=star-args
+ return self._template('login/pam.html', **context)
def root(self, *args, **kwargs):
op = getattr(self, cherrypy.request.method, self.GET)
if callable(op):
return op(*args, **kwargs)
+ def create_tmpl_context(self, **kwargs):
+ next_url = None
+ if self.lm.next_login is not None:
+ next_url = self.lm.next_login.path
+
+ context = {
+ "title": 'Login',
+ "action": '%s/login/pam' % self.basepath,
+ "service_name": self.lm.service_name,
+ "username_text": self.lm.username_text,
+ "password_text": self.lm.password_text,
+ "description": self.lm.help_text,
+ "next_url": next_url,
+ }
+ context.update(kwargs)
+ return context
+
class LoginManager(LoginManagerBase):
diff --git a/templates/login/pam.html b/templates/login/pam.html
index 0e83f12..b856731 100644
--- a/templates/login/pam.html
+++ b/templates/login/pam.html
@@ -1,36 +1,43 @@
-<!doctype html>
-<html lang="en">
-<head>
- <meta charset="UTF-8"></meta>
- <title>{{ title }}</title>
- <link href="{{ basepath }}/ui/ipsilon.css" type="text/css" rel="stylesheet"></link>
- <link href="{{ basepath }}/ui/favicon.ico" type="image/ico" rel="icon"></link>
-</head>
-<body>
- <div id="container">
- <div id="logo">
- <p>Ipsilon</p>
- </div>
- <div id="login">
- <p>
- {{ help_text }}
- </p>
- <form id="login_form" action="{{ action }}" method="post" enctype="application/x-www-form-urlencoded">
- <p>
- <label for="username">{{ username_text }}</label>
- <br>
- <input id="username" name="login_name" value="" size="32" type="text">
- </p>
- <p>
- <label for="password">{{ password_text }}</label>
- <br>
- <input id="password" name="login_password" value="" size="32" type="password">
- </p>
- <p>
- <input id="submit" name="submit" value="Login" type="submit">
- </p>
- </form>
- </div>
+{% extends "master.html" %}
+{% block main %}
+
+{% if error %}
+<div class="col-sm-12">
+ <div class="alert alert-danger">
+ <p>{{ error }}</p>
+ </div>
+</div>
+
+{% endif %}
+
+<div class="col-sm-7 col-md-6 col-lg-5 login">
+ <form class="form-horizontal" role="form" id="login_form" action="{{ action }}" method="post" enctype="application/x-www-form-urlencoded">
+ <div class="form-group {% if error_username %} has-error{% endif %}">
+ <label for="login_name" class="col-sm-2 col-md-2 control-label">{{ username_text }}</label>
+ <div class="col-sm-10 col-md-10">
+ <input type="text" class="form-control" name="login_name" id="login_name" placeholder="" tabindex="1" value="{{ username | e }}">
+ </div>
</div>
-</body>
-</html>
+ <div class="form-group{% if error_password %} has-error{% endif %}">
+ <label for="login_password" class="col-sm-2 col-md-2 control-label">{{ password_text }}</label>
+ <div class="col-sm-10 col-md-10">
+ <input type="password" class="form-control" name="login_password" id="login_password" placeholder="" tabindex="2">
+ </div>
+ </div>
+ <div class="form-group">
+ <div class="col-sm-offset-2 col-md-offset-2 col-xs-12 col-sm-10 col-md-10 submit">
+ <a href="{{ basepath }}/" title="Cancel" class="btn btn-link" tabindex="4">Cancel</a>
+ {% if next_url %}
+ <a href="{{ next_url }}" title="Next authentication method" class="btn btn-link" tabindex="5">Next method </a>
+ {% endif %}
+ <button type="submit" value="login" class="btn btn-primary btn-lg" tabindex="3">Log In</button>
+ </div>
+ </div>
+ </form>
+</div>
+
+<div class="col-sm-5 col-md-6 col-lg-7 details">
+ <p>{{description}}</p>
+</div>
+
+{% endblock %}