mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #1294 from SchrodingersGat/login-static-files
Allow access to static files without being logged in
This commit is contained in:
commit
4431082440
@ -47,7 +47,12 @@ class AuthRequiredMiddleware(object):
|
|||||||
|
|
||||||
authorized = False
|
authorized = False
|
||||||
|
|
||||||
if 'Authorization' in request.headers.keys():
|
# Allow static files to be accessed without auth
|
||||||
|
# Important for e.g. login page
|
||||||
|
if request.path_info.startswith('/static/'):
|
||||||
|
authorized = True
|
||||||
|
|
||||||
|
elif 'Authorization' in request.headers.keys():
|
||||||
auth = request.headers['Authorization'].strip()
|
auth = request.headers['Authorization'].strip()
|
||||||
|
|
||||||
if auth.startswith('Token') and len(auth.split()) == 2:
|
if auth.startswith('Token') and len(auth.split()) == 2:
|
||||||
@ -56,7 +61,7 @@ class AuthRequiredMiddleware(object):
|
|||||||
# Does the provided token match a valid user?
|
# Does the provided token match a valid user?
|
||||||
if Token.objects.filter(key=token).exists():
|
if Token.objects.filter(key=token).exists():
|
||||||
|
|
||||||
allowed = ['/api/', '/media/', '/static/']
|
allowed = ['/api/', '/media/']
|
||||||
|
|
||||||
# Only allow token-auth for /media/ or /static/ dirs!
|
# Only allow token-auth for /media/ or /static/ dirs!
|
||||||
if any([request.path_info.startswith(a) for a in allowed]):
|
if any([request.path_info.startswith(a) for a in allowed]):
|
||||||
|
@ -11,6 +11,45 @@
|
|||||||
--label-yellow: #fdc82a;
|
--label-yellow: #fdc82a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.login-screen {
|
||||||
|
background-image: url("/static/img/paper_splash.jpg");
|
||||||
|
background-size: cover;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
height: 100%;
|
||||||
|
font-family: 'Numans', sans-serif;
|
||||||
|
color: #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-container {
|
||||||
|
left: 50%;
|
||||||
|
position: fixed;
|
||||||
|
top: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
width: 30%;
|
||||||
|
align-content: center;
|
||||||
|
border-radius: 15px;
|
||||||
|
padding: 20px;
|
||||||
|
padding-bottom: 35px;
|
||||||
|
background-color: rgba(50, 50, 50, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-header {
|
||||||
|
padding-right: 30px;
|
||||||
|
margin-right: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-container input {
|
||||||
|
background-color: rgba(250, 250, 250, 0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-button {
|
||||||
|
background-color: rgba(250, 250, 250, 0.9);
|
||||||
|
color: #333;
|
||||||
|
border-color: #AAA;
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
.markdownx .row {
|
.markdownx .row {
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
@ -708,13 +747,6 @@ input[type="submit"] {
|
|||||||
color: #e00;
|
color: #e00;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login {
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.part-allocation {
|
.part-allocation {
|
||||||
padding: 3px 10px;
|
padding: 3px 10px;
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
|
BIN
InvenTree/InvenTree/static/img/paper_splash.jpg
Normal file
BIN
InvenTree/InvenTree/static/img/paper_splash.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 MiB |
@ -14,38 +14,73 @@
|
|||||||
<link rel="stylesheet" href="{% static 'css/select2.css' %}">
|
<link rel="stylesheet" href="{% static 'css/select2.css' %}">
|
||||||
<link rel="stylesheet" href="{% static 'css/bootstrap-table.css' %}">
|
<link rel="stylesheet" href="{% static 'css/bootstrap-table.css' %}">
|
||||||
<link rel="stylesheet" href="{% static 'css/inventree.css' %}">
|
<link rel="stylesheet" href="{% static 'css/inventree.css' %}">
|
||||||
|
<link rel="stylesheet" href="{% static 'fontawesome/css/brands.css' %}">
|
||||||
|
<link rel="stylesheet" href="{% static 'fontawesome/css/solid.css' %}">
|
||||||
|
|
||||||
|
<script type='text/javascript' src="{% static 'fontawesome/js/solid.js' %}"></script>
|
||||||
|
<script type='text/javascript' src="{% static 'fontawesome/js/brands.js' %}"></script>
|
||||||
|
<script type='text/javascript' src="{% static 'fontawesome/js/fontawesome.js' %}"></script>
|
||||||
|
|
||||||
<title>
|
<title>
|
||||||
InvenTree
|
InvenTree
|
||||||
</title>
|
</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body class='login-screen'>
|
||||||
|
<!--
|
||||||
|
Background Image Attribution: https://unsplash.com/photos/Ixvv3YZkd7w
|
||||||
|
-->
|
||||||
|
|
||||||
<div class='main body-wrapper'>
|
<div class='main body-wrapper login-screen'>
|
||||||
|
|
||||||
|
<div class='login-container'>
|
||||||
|
<div class="row">
|
||||||
|
<div class='container-fluid'>
|
||||||
|
<div class='clearfix content-heading login-header'>
|
||||||
|
<img class="pull-left" src="{% static 'img/inventree.png' %}" width="60" height="60"/>
|
||||||
|
<span><h3>InvenTree</h3></span>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
|
||||||
<div class='login'>
|
<div class='container-fluid'>
|
||||||
<div class="row">
|
<form method="post" action=''>
|
||||||
<div class='container-fluid'>
|
{% csrf_token %}
|
||||||
<div class='clearfix content-heading'>
|
|
||||||
<img class="pull-left" src="{% static 'img/inventree.png' %}" width="60" height="60"/> <h3>InvenTree</h3>
|
|
||||||
</div>
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<div class='container-fluid'>
|
{% load crispy_forms_tags %}
|
||||||
<form method="post" action=''>
|
|
||||||
{% csrf_token %}
|
|
||||||
{% load crispy_forms_tags %}
|
|
||||||
|
|
||||||
{{ form|crispy }}
|
<div id="div_id_username" class="form-group">
|
||||||
|
<label for="id_username" class="control-label requiredField">{% trans "Username" %}<span class="asteriskField">*</span></label>
|
||||||
|
<div class="controls ">
|
||||||
|
<div class='input-group'>
|
||||||
|
<div class='input-group-addon'>
|
||||||
|
<span class='fas fa-user'></span>
|
||||||
|
</div>
|
||||||
|
<input type="text" name="username" autofocus autocapitalize="none" autocomplete="username" maxlength="150" class="textinput textInput form-control" required id="id_username">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<button class='pull-right btn btn-primary' type="submit">{% trans "Login" %}</button>
|
<div id="div_id_password" class="form-group">
|
||||||
</form>
|
<label for="id_password" class="control-label requiredField">{% trans "Password" %}<span class="asteriskField">*</span></label>
|
||||||
|
<div class='controls'>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class='input-group-addon'>
|
||||||
|
<span class='fas fa-key'></span>
|
||||||
|
</div>
|
||||||
|
<input type="password" name="password" autocomplete="current-password" class="textinput textInput form-control" required id="id_password">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<button class='pull-right btn btn-primary login-button' type="submit">{% trans "Login" %}</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user