mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 13:41:15 -07:00
Add modal popup for admin login from menu
This commit is contained in:
parent
1622b0fa29
commit
2f8e768c5c
4 changed files with 72 additions and 7 deletions
|
@ -227,7 +227,7 @@ from plexpy.helpers import anon_url
|
||||||
<li><a href="#" id="nav-restart"><i class="fa fa-fw fa-refresh"></i> Restart</a></li>
|
<li><a href="#" id="nav-restart"><i class="fa fa-fw fa-refresh"></i> Restart</a></li>
|
||||||
<li><a href="#" id="nav-shutdown"><i class="fa fa-fw fa-power-off"></i> Shutdown</a></li>
|
<li><a href="#" id="nav-shutdown"><i class="fa fa-fw fa-power-off"></i> Shutdown</a></li>
|
||||||
% else:
|
% else:
|
||||||
<li><a href="${http_root}auth/login"><i class="fa fa-fw fa-lock"></i> Admin Login</a></li>
|
<li><a href="#" data-target="#admin-login-modal" data-toggle="modal"><i class="fa fa-fw fa-lock"></i> Admin Login</a></li>
|
||||||
<li role="separator" class="divider"></li>
|
<li role="separator" class="divider"></li>
|
||||||
% endif
|
% endif
|
||||||
% if _session['expiry']:
|
% if _session['expiry']:
|
||||||
|
@ -241,6 +241,48 @@ from plexpy.helpers import anon_url
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
% if _session['user_group'] != 'admin':
|
||||||
|
<div id="admin-login-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="admin-login-modal">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<form action="${http_root}auth/login" method="post">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-remove"></i></button>
|
||||||
|
<h4 class="modal-title">Admin Login</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="col-md-6" style="margin: auto;">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="username" class="control-label">
|
||||||
|
Username
|
||||||
|
</label>
|
||||||
|
<input type="text" id="username" name="username" class="form-control" autocorrect="off" autocapitalize="off">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="password" class="control-label">
|
||||||
|
Password
|
||||||
|
</label>
|
||||||
|
<input type="password" id="password" name="password" class="form-control">
|
||||||
|
</div>
|
||||||
|
<div class="form-footer">
|
||||||
|
<div class="remember-group">
|
||||||
|
<label class="control-label">
|
||||||
|
<input type="checkbox" id="remember_me" name="remember_me" title="for 30 days" value="1" checked="checked" /> Remember me
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="submit" class="btn btn-bright login-button"><i class="fa fa-sign-in"></i> Sign In</button>
|
||||||
|
</div>
|
||||||
|
<input type="hidden" id="admin_login" name="admin_login" value="1" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
% endif
|
||||||
|
|
||||||
${next.headerIncludes()}
|
${next.headerIncludes()}
|
||||||
<div class="body-container">
|
<div class="body-container">
|
||||||
${next.body()}
|
${next.body()}
|
||||||
|
@ -322,6 +364,12 @@ ${next.headerIncludes()}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
% if _session['user_group'] != 'admin':
|
||||||
|
$('#admin-login-modal').on('shown.bs.modal', function () {
|
||||||
|
$('#admin-login-modal #username').focus()
|
||||||
|
})
|
||||||
|
% endif
|
||||||
</script>
|
</script>
|
||||||
${next.javascriptIncludes()}
|
${next.javascriptIncludes()}
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -2908,4 +2908,18 @@ a.no-highlight:hover {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
#admin-login-modal .form-group label {
|
||||||
|
font-weight: 400;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
#admin-login-modal .remember-group {
|
||||||
|
float: left;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
#admin-login-modal .remember-group .control-label {
|
||||||
|
display: inline;
|
||||||
|
margin-bottom: 0;
|
||||||
|
font-weight: 400;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
|
@ -31,13 +31,13 @@
|
||||||
${msg}
|
${msg}
|
||||||
</div>
|
</div>
|
||||||
% endif
|
% endif
|
||||||
<div class="username-group form-group">
|
<div class="form-group">
|
||||||
<label for="username" class="control-label">
|
<label for="username" class="control-label">
|
||||||
Username
|
Username
|
||||||
</label>
|
</label>
|
||||||
<input type="text" id="username" name="username" class="form-control" autocorrect="off" autocapitalize="off" value="${username}" autofocus>
|
<input type="text" id="username" name="username" class="form-control" autocorrect="off" autocapitalize="off" value="${username}" autofocus>
|
||||||
</div>
|
</div>
|
||||||
<div class="password-group form-group">
|
<div class="form-group">
|
||||||
<label for="password" class="control-label">
|
<label for="password" class="control-label">
|
||||||
Password
|
Password
|
||||||
</label>
|
</label>
|
||||||
|
|
|
@ -98,7 +98,7 @@ def user_login(username=None, password=None):
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def check_credentials(username, password):
|
def check_credentials(username, password, admin_login='0'):
|
||||||
"""Verifies credentials for username and password.
|
"""Verifies credentials for username and password.
|
||||||
Returns True and the user group on success or False and no user group"""
|
Returns True and the user group on success or False and no user group"""
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ def check_credentials(username, password):
|
||||||
return True, u'admin'
|
return True, u'admin'
|
||||||
elif username == plexpy.CONFIG.HTTP_USERNAME and password == plexpy.CONFIG.HTTP_PASSWORD:
|
elif username == plexpy.CONFIG.HTTP_USERNAME and password == plexpy.CONFIG.HTTP_PASSWORD:
|
||||||
return True, u'admin'
|
return True, u'admin'
|
||||||
elif plexpy.CONFIG.ALLOW_GUEST_ACCESS and user_login(username, password):
|
elif not admin_login == '1' and plexpy.CONFIG.ALLOW_GUEST_ACCESS and user_login(username, password):
|
||||||
return True, u'guest'
|
return True, u'guest'
|
||||||
else:
|
else:
|
||||||
return False, None
|
return False, None
|
||||||
|
@ -202,14 +202,14 @@ class AuthController(object):
|
||||||
raise cherrypy.HTTPRedirect("login")
|
raise cherrypy.HTTPRedirect("login")
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def login(self, username=None, password=None, remember_me='0'):
|
def login(self, username=None, password=None, remember_me='0', admin_login='0'):
|
||||||
if not cherrypy.config.get('tools.sessions.on'):
|
if not cherrypy.config.get('tools.sessions.on'):
|
||||||
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT)
|
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT)
|
||||||
|
|
||||||
if username is None or password is None:
|
if username is None or password is None:
|
||||||
return self.get_loginform()
|
return self.get_loginform()
|
||||||
|
|
||||||
(vaild_login, user_group) = check_credentials(username, password)
|
(vaild_login, user_group) = check_credentials(username, password, admin_login)
|
||||||
|
|
||||||
if vaild_login:
|
if vaild_login:
|
||||||
if user_group == 'guest':
|
if user_group == 'guest':
|
||||||
|
@ -234,6 +234,9 @@ class AuthController(object):
|
||||||
self.on_login(username)
|
self.on_login(username)
|
||||||
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT)
|
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT)
|
||||||
|
|
||||||
|
elif admin_login == '1':
|
||||||
|
logger.debug(u"Invalid admin login attempt from '%s'." % username)
|
||||||
|
raise cherrypy.HTTPRedirect(plexpy.HTTP_ROOT)
|
||||||
else:
|
else:
|
||||||
logger.debug(u"Invalid login attempt from '%s'." % username)
|
logger.debug(u"Invalid login attempt from '%s'." % username)
|
||||||
return self.get_loginform(username, u"Incorrect username/email or password.")
|
return self.get_loginform(username, u"Incorrect username/email or password.")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue