Browse Source

HUE-629 the very first login warns about creating a superuser

Enrico Berti 13 years ago
parent
commit
19ba079a25

+ 6 - 0
desktop/core/src/desktop/auth/views.py

@@ -100,10 +100,16 @@ def dt_login(request):
   else:
     form = django.contrib.auth.forms.AuthenticationForm()
   request.session.set_test_cookie()
+  backends = get_backends()
+  first_login_ever = False
+  for be in backends:
+    if isinstance(be, AllowFirstUserDjangoBackend) and be.is_first_login_ever():
+      first_login_ever = True
   return render('login.mako', request, {
     'action': urlresolvers.reverse('desktop.auth.views.dt_login'),
     'form': form,
     'next': redirect_to,
+    'first_login_ever': first_login_ever,
   })
 
 

+ 25 - 7
desktop/core/src/desktop/templates/login.mako

@@ -23,13 +23,13 @@
 	<title>jHue Login</title>
 	<link rel="stylesheet" href="/static/ext/css/bootstrap.min.css" type="text/css" media="screen" title="no title" charset="utf-8" />
 	<link rel="stylesheet" href="/static/css/jhue.css" type="text/css" media="screen" title="no title" charset="utf-8" />
-	
+
 	<style type="text/css">
       body {
         padding-top: 100px;
       }
     </style>
-	<script src="/static/ext/js/jquery/jquery-1.7.min.js" type="text/javascript" charset="utf-8"></script>	
+	<script src="/static/ext/js/jquery/jquery-1.7.min.js" type="text/javascript" charset="utf-8"></script>
 
 	<script type="text/javascript" charset="utf-8">
 		$(document).ready(function(){
@@ -40,10 +40,10 @@
 			}).change(function(){
 				$(this).closest("form").submit();
 			});
-			
+
 		});
 	</script>
-	
+
 </head>
 <body>
 	<div class="topbar">
@@ -63,8 +63,9 @@
 			</div>
 		</div>
 	</div>
-	
+
 	<div class="container">
+
 		<div class="row">
 			<div class="span6 offset5">
     			<form method="POST" action="${action}" class="form-stacked">
@@ -81,14 +82,31 @@
 						</div>
 					</div>
 					<div class="actions">
-			    		<input type="submit" class="btn primary" value="Sign in" />
+						%if first_login_ever==True:
+							<input type="submit" class="btn primary" value="Sign up" />
+						%else:
+							<input type="submit" class="btn primary" value="Sign in" />
+						%endif
 			    		<input type="hidden" name="next" value="${next}" />
 					</div>
 				</form>
+
+			</div>
+		</div>
+
+		%if first_login_ever==True:
+		<div class="row">
+			<div class="span10 offset3">
+				<div class="alert-message block-message warning">
+					<p>Since this is your first time logging in,
+				    please pick any username and password. Be sure to remember these, as <strong>	hey
+					    will become your superuser account for Hue</strong>.</p>
 				</div>
 			</div>
+		</div>
+		%endif
 	</div>
-	
+
 
 </body>
 </html>