mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'bug/ReworkDefautPublicHandler' into 'dev'
Rework Public Route to Fix issue 133 See merge request crafty-controller/crafty-4!538
This commit is contained in:
commit
a46a962c86
@ -5,6 +5,7 @@
|
||||
### Bug fixes
|
||||
- Fix local java server imports. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/529))
|
||||
- Fix Schedule Restore | Add Backup Config Preservation. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/533))
|
||||
- Rework `/public` Route. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/538))
|
||||
### Tweaks
|
||||
- Added further login screen customisation settings. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/531))
|
||||
- Set backup filename to use same time as schedule. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/534))
|
||||
|
@ -175,7 +175,6 @@ class ServerInstance:
|
||||
self.name = server_name
|
||||
self.settings = server_data_obj
|
||||
|
||||
self.stats_helper.init_database(server_id)
|
||||
self.record_server_stats()
|
||||
|
||||
# build our server run command
|
||||
|
@ -17,6 +17,5 @@ class DefaultHandler(BaseHandler):
|
||||
)
|
||||
else:
|
||||
self.redirect(
|
||||
"/public/login",
|
||||
# translate=self.translator.translate,
|
||||
"/login",
|
||||
)
|
||||
|
@ -62,15 +62,15 @@ class PublicHandler(BaseHandler):
|
||||
self.clear_cookie("token")
|
||||
# self.clear_cookie("user")
|
||||
# self.clear_cookie("user_data")
|
||||
self.redirect("/public/login")
|
||||
self.redirect("/login")
|
||||
return
|
||||
|
||||
# if we have no page, let's go to login
|
||||
else:
|
||||
if self.request.query:
|
||||
self.redirect("/public/login?" + self.request.query)
|
||||
self.redirect("/login?" + self.request.query)
|
||||
else:
|
||||
self.redirect("/public/login")
|
||||
self.redirect("/login")
|
||||
return
|
||||
|
||||
self.render(
|
||||
@ -97,9 +97,9 @@ class PublicHandler(BaseHandler):
|
||||
|
||||
if page == "login":
|
||||
|
||||
next_page = "/public/login"
|
||||
next_page = "/login"
|
||||
if self.request.query:
|
||||
next_page = "/public/login?" + self.request.query
|
||||
next_page = "/login?" + self.request.query
|
||||
|
||||
entered_username = bleach.clean(self.get_argument("username"))
|
||||
entered_password = bleach.clean(self.get_argument("password"))
|
||||
@ -114,11 +114,9 @@ class PublicHandler(BaseHandler):
|
||||
# self.clear_cookie("user_data")
|
||||
self.clear_cookie("token")
|
||||
if self.request.query:
|
||||
self.redirect(
|
||||
f"/public/login?error_msg={error_msg}&{self.request.query}"
|
||||
)
|
||||
self.redirect(f"/login?error_msg={error_msg}&{self.request.query}")
|
||||
else:
|
||||
self.redirect(f"/public/login?error_msg={error_msg}")
|
||||
self.redirect(f"/login?error_msg={error_msg}")
|
||||
return
|
||||
|
||||
# if we don't have a user
|
||||
@ -128,11 +126,9 @@ class PublicHandler(BaseHandler):
|
||||
# self.clear_cookie("user_data")
|
||||
self.clear_cookie("token")
|
||||
if self.request.query:
|
||||
self.redirect(
|
||||
f"/public/login?error_msg={error_msg}&{self.request.query}"
|
||||
)
|
||||
self.redirect(f"/login?error_msg={error_msg}&{self.request.query}")
|
||||
else:
|
||||
self.redirect(f"/public/login?error_msg={error_msg}")
|
||||
self.redirect(f"/login?error_msg={error_msg}")
|
||||
return
|
||||
|
||||
# if they are disabled
|
||||
@ -145,11 +141,9 @@ class PublicHandler(BaseHandler):
|
||||
# self.clear_cookie("user_data")
|
||||
self.clear_cookie("token")
|
||||
if self.request.query:
|
||||
self.redirect(
|
||||
f"/public/login?error_msg={error_msg}&{self.request.query}"
|
||||
)
|
||||
self.redirect(f"/login?error_msg={error_msg}&{self.request.query}")
|
||||
else:
|
||||
self.redirect(f"/public/login?error_msg={error_msg}")
|
||||
self.redirect(f"/login?error_msg={error_msg}")
|
||||
return
|
||||
|
||||
login_result = self.helper.verify_pass(entered_password, user_data.password)
|
||||
@ -188,13 +182,11 @@ class PublicHandler(BaseHandler):
|
||||
user_data.user_id, "Tried to log in", 0, self.get_remote_ip()
|
||||
)
|
||||
if self.request.query:
|
||||
self.redirect(
|
||||
f"/public/login?error_msg={error_msg}&{self.request.query}"
|
||||
)
|
||||
self.redirect(f"/login?error_msg={error_msg}&{self.request.query}")
|
||||
else:
|
||||
self.redirect(f"/public/login?error_msg={error_msg}")
|
||||
self.redirect(f"/login?error_msg={error_msg}")
|
||||
else:
|
||||
if self.request.query:
|
||||
self.redirect("/public/login?" + self.request.query)
|
||||
self.redirect("/login?" + self.request.query)
|
||||
else:
|
||||
self.redirect("/public/login")
|
||||
self.redirect("/login")
|
||||
|
@ -147,7 +147,6 @@ class Webserver:
|
||||
}
|
||||
handlers = [
|
||||
(r"/", DefaultHandler, handler_args),
|
||||
(r"/public/(.*)", PublicHandler, handler_args),
|
||||
(r"/panel/(.*)", PanelHandler, handler_args),
|
||||
(r"/server/(.*)", ServerHandler, handler_args),
|
||||
(r"/ajax/(.*)", AjaxHandler, handler_args),
|
||||
@ -168,6 +167,9 @@ class Webserver:
|
||||
(r"/api/v1/users/delete_user", DeleteUser, handler_args),
|
||||
# API Routes V2
|
||||
*api_handlers(handler_args),
|
||||
# Using this one at the end
|
||||
# to catch all the other requests to Public Handler
|
||||
(r"/(.*)", PublicHandler, handler_args),
|
||||
]
|
||||
|
||||
app = tornado.web.Application(
|
||||
@ -179,21 +181,14 @@ class Webserver:
|
||||
xsrf_cookies=True,
|
||||
autoreload=False,
|
||||
log_function=self.log_function,
|
||||
login_url="/public/login",
|
||||
login_url="/login",
|
||||
default_handler_class=PublicHandler,
|
||||
static_handler_class=CustomStaticHandler,
|
||||
serve_traceback=debug_errors,
|
||||
)
|
||||
http_handers = [
|
||||
(r"/", HTTPHandler, handler_args),
|
||||
(r"/public/(.*)", HTTPHandlerPage, handler_args),
|
||||
(r"/panel/(.*)", HTTPHandlerPage, handler_args),
|
||||
(r"/server/(.*)", HTTPHandlerPage, handler_args),
|
||||
(r"/ajax/(.*)", HTTPHandlerPage, handler_args),
|
||||
(r"/api/stats/servers", HTTPHandlerPage, handler_args),
|
||||
(r"/api/stats/node", HTTPHandlerPage, handler_args),
|
||||
(r"/ws", HTTPHandlerPage, handler_args),
|
||||
(r"/upload", HTTPHandlerPage, handler_args),
|
||||
(r"/(.+)", HTTPHandlerPage, handler_args),
|
||||
]
|
||||
http_app = tornado.web.Application(
|
||||
http_handers,
|
||||
@ -205,7 +200,7 @@ class Webserver:
|
||||
autoreload=False,
|
||||
log_function=self.log_function,
|
||||
default_handler_class=HTTPHandler,
|
||||
login_url="/public/login",
|
||||
login_url="/login",
|
||||
serve_traceback=debug_errors,
|
||||
)
|
||||
|
||||
|
@ -1,57 +1,59 @@
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link count-indicator">
|
||||
<i class="fas fa-broadcast-tower
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link count-indicator">
|
||||
<i class="fas fa-broadcast-tower
|
||||
{% if data.get('update_available') %}
|
||||
text-danger
|
||||
{% end %}
|
||||
"></i>
|
||||
<!-- <span class="count bg-success">3</span>-->
|
||||
</a>
|
||||
</li>
|
||||
<!-- <span class="count bg-success">3</span>-->
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link count-indicator" href="/panel/panel_config">
|
||||
<i class="fas fa-cogs"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link count-indicator" href="/panel/panel_config">
|
||||
<i class="fas fa-cogs"></i>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item dropdown user-dropdown">
|
||||
<a class="nav-link dropdown-toggle" id="UserDropdown" href="#" data-toggle="dropdown" aria-expanded="false">
|
||||
<img class="img-xs rounded-circle profile-picture" onerror="pfpError(this)" src="{{ data['user_data']['pfp'] }}" alt="Profile image"> </a>
|
||||
<div class="dropdown-menu dropdown-menu-right navbar-dropdown" aria-labelledby="UserDropdown">
|
||||
<div class="dropdown-header text-center">
|
||||
<img class="img-md rounded-circle profile-picture" onerror="pfpError(this)" src="{{ data['user_data']['pfp'] }}" alt="Profile image">
|
||||
<p class="mb-1 mt-3 font-weight-semibold">{{ data['user_data']['username'] }}</p>
|
||||
<p class="font-weight-light text-muted mb-0">Roles: </p>
|
||||
{% for r in data['user_role'] %}
|
||||
<p class="font-weight-light text-muted mb-0">{{ r }}</p>
|
||||
{% end %}
|
||||
{% if data.get('api_key') %}
|
||||
<p class="mt-3">Logged in as API key "{{ data['api_key']['name'] }}"</p>
|
||||
{% end %}
|
||||
<p class="font-weight-light text-muted mb-0">Email: {{ data['user_data']['email'] }}</p>
|
||||
</div>
|
||||
{% if data['user_data']['preparing'] %}
|
||||
<span class="dropdown-item" id="support_progress"><i class="dropdown-item-icon mdi mdi-download-outline text-primary"></i>{{ translate('notify', 'supportLogs', data['lang']) }}<br><br></span>
|
||||
<span class="dropdown-item" id="support_progress"><div class="support_progress" style="height: 15px; width: 100%;">
|
||||
<div class="progress-bar progress-bar-striped progress-bar-animated" id="logs_progress_bar" role="progressbar" style="width:0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
|
||||
</div></span>
|
||||
{% else %}
|
||||
<a class="dropdown-item" id="support_logs" ><i class="dropdown-item-icon mdi mdi-download-outline text-primary"></i>{{ translate('notify', 'supportLogs', data['lang']) }}</i></a>
|
||||
<li class="nav-item dropdown user-dropdown">
|
||||
<a class="nav-link dropdown-toggle" id="UserDropdown" href="#" data-toggle="dropdown" aria-expanded="false">
|
||||
<img class="img-xs rounded-circle profile-picture" onerror="pfpError(this)" src="{{ data['user_data']['pfp'] }}" alt="Profile image"> </a>
|
||||
<div class="dropdown-menu dropdown-menu-right navbar-dropdown" aria-labelledby="UserDropdown">
|
||||
<div class="dropdown-header text-center">
|
||||
<img class="img-md rounded-circle profile-picture" onerror="pfpError(this)" src="{{ data['user_data']['pfp'] }}" alt="Profile image">
|
||||
<p class="mb-1 mt-3 font-weight-semibold">{{ data['user_data']['username'] }}</p>
|
||||
<p class="font-weight-light text-muted mb-0">Roles: </p>
|
||||
{% for r in data['user_role'] %}
|
||||
<p class="font-weight-light text-muted mb-0">{{ r }}</p>
|
||||
{% end %}
|
||||
{% if data['superuser'] %}
|
||||
<a class="dropdown-item" href="/panel/activity_logs"><i class="dropdown-item-icon mdi mdi-calendar-check-outline text-primary"></i>{{ translate('notify', 'activityLog', data['lang']) }}</a>
|
||||
{% if data.get('api_key') %}
|
||||
<p class="mt-3">Logged in as API key "{{ data['api_key']['name'] }}"</p>
|
||||
{% end %}
|
||||
<a class="dropdown-item" href="/public/logout"><i class="dropdown-item-icon mdi mdi-power text-primary"></i>{{ translate('notify', 'logout', data['lang']) }}</a>
|
||||
<p class="font-weight-light text-muted mb-0">Email: {{ data['user_data']['email'] }}</p>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
{% if data['user_data']['preparing'] %}
|
||||
<span class="dropdown-item" id="support_progress"><i class="dropdown-item-icon mdi mdi-download-outline text-primary"></i>{{ translate('notify', 'supportLogs', data['lang']) }}<br><br></span>
|
||||
<span class="dropdown-item" id="support_progress">
|
||||
<div class="support_progress" style="height: 15px; width: 100%;">
|
||||
<div class="progress-bar progress-bar-striped progress-bar-animated" id="logs_progress_bar" role="progressbar" style="width:0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
|
||||
</div>
|
||||
</span>
|
||||
{% else %}
|
||||
<a class="dropdown-item" id="support_logs"><i class="dropdown-item-icon mdi mdi-download-outline text-primary"></i>{{ translate('notify', 'supportLogs', data['lang']) }}</i></a>
|
||||
{% end %}
|
||||
{% if data['superuser'] %}
|
||||
<a class="dropdown-item" href="/panel/activity_logs"><i class="dropdown-item-icon mdi mdi-calendar-check-outline text-primary"></i>{{ translate('notify', 'activityLog', data['lang']) }}</a>
|
||||
{% end %}
|
||||
<a class="dropdown-item" href="/logout"><i class="dropdown-item-icon mdi mdi-power text-primary"></i>{{ translate('notify', 'logout', data['lang']) }}</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<script>
|
||||
function pfpError(image) {
|
||||
<script>
|
||||
function pfpError(image) {
|
||||
image.onerror = "";
|
||||
image.src = "/static/assets/images/faces-clipart/pic-3.png";
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
</script>
|
@ -71,25 +71,25 @@
|
||||
}
|
||||
</style>
|
||||
{% if data['query'] %}
|
||||
<form action="/public/login?{{ data['query'] }}" method="post">
|
||||
<form action="/login?{{ data['query'] }}" method="post">
|
||||
{% else %}
|
||||
<form action="/public/login" method="post">
|
||||
<form action="/login" method="post">
|
||||
{% end %}
|
||||
{% raw xsrf_form_html() %}
|
||||
<div class="form-group">
|
||||
<label class="label">{{ translate('login', 'username', data['lang']) }}</label>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control login-text-input login-input"
|
||||
placeholder="{{ translate('login', 'username', data['lang']) }}" name="username" id="username"
|
||||
required="true">
|
||||
placeholder="{{ translate('login', 'username', data['lang']) }}" name="username" id="username"
|
||||
required="true">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="label">{{ translate('login', 'password', data['lang']) }}</label>
|
||||
<div class="input-group">
|
||||
<input type="password" class="form-control login-text-input login-input"
|
||||
placeholder="{{ translate('login', 'password', data['lang']) }}" name="password" id="password"
|
||||
required="true">
|
||||
placeholder="{{ translate('login', 'password', data['lang']) }}" name="password" id="password"
|
||||
required="true">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
@ -5,61 +5,61 @@
|
||||
{% block content %}
|
||||
|
||||
<div class="auto-form-wrapper">
|
||||
<div class="text-center">
|
||||
<div class="text-center">
|
||||
<!-- <img src="/static/assets/images/logo_long.svg">-->
|
||||
{{ _('Configure Your Existing Server') }}<br /><br />
|
||||
{{ _('Configure Your Existing Server') }}<br /><br />
|
||||
</div>
|
||||
<form action="/login" method="post">
|
||||
{% raw xsrf_form_html() %}
|
||||
|
||||
<div class="form-group">
|
||||
<label class="label">
|
||||
{{ _('Server Name') }} - <small>{{ _('Example Survival Server') }}</small>
|
||||
</label>
|
||||
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="{{ _('Server Name') }}" name="server_name" value="{{_('MyFirstServer') }}" maxlength="55">
|
||||
</div>
|
||||
</div>
|
||||
<form action="/public/login" method="post">
|
||||
{% raw xsrf_form_html() %}
|
||||
|
||||
<div class="form-group">
|
||||
<label class="label">
|
||||
{{ _('Server Name') }} - <small>{{ _('Example Survival Server') }}</small>
|
||||
</label>
|
||||
<div class="form-group">
|
||||
{% if data['is_windows'] %}
|
||||
<label class="label">
|
||||
{{ _('Server Path') }} - <small>{{ _('Example c:\minecraft\server') }}</small>
|
||||
</label>
|
||||
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="{{ _('Server Name') }}" name="server_name" value="{{_('MyFirstServer') }}" maxlength="55">
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="{{ _('Server Path') }}" name="server_path"
|
||||
value="c:\windows\minecraft" maxlength="255">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
{% if data['is_windows'] %}
|
||||
<label class="label">
|
||||
{{ _('Server Path') }} - <small>{{ _('Example c:\minecraft\server') }}</small>
|
||||
</label>
|
||||
{% else %}
|
||||
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="{{ _('Server Path') }}" name="server_path"
|
||||
value="c:\windows\minecraft" maxlength="255">
|
||||
</div>
|
||||
<label class="label">
|
||||
{{ _('Server Path') }} - <small>{{ _("Example: /var/opt/minecraft/server") }}</small>
|
||||
</label>
|
||||
|
||||
{% else %}
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="{{ _('Server Path') }}" name="server_path"
|
||||
value="c:\windows\minecraft" maxlength="255">
|
||||
</div>
|
||||
{% end %}
|
||||
</div>
|
||||
|
||||
<label class="label">
|
||||
{{ _('Server Path') }} - <small>{{ _("Example: /var/opt/minecraft/server") }}</small>
|
||||
</label>
|
||||
<div class="form-group">
|
||||
<label class="label">
|
||||
{{ _('Server Jar') }} - <small>{{ _('Example paper.jar') }}</small>
|
||||
</label>
|
||||
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="{{ _('Server Path') }}" name="server_path"
|
||||
value="c:\windows\minecraft" maxlength="255">
|
||||
</div>
|
||||
{% end %}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="label">
|
||||
{{ _('Server Jar') }} - <small>{{ _('Example paper.jar') }}</small>
|
||||
</label>
|
||||
|
||||
<input type="text" class="form-control" placeholder="{{ _('Server Jar') }}" name="server_jar" value="paper.jar" maxlength="255">
|
||||
</div>
|
||||
<input type="text" class="form-control" placeholder="{{ _('Server Jar') }}" name="server_jar" value="paper.jar" maxlength="255">
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<button class="btn btn-primary submit-btn btn-block"><i class="fas fa-save"></i> Save</button>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button class="btn btn-primary submit-btn btn-block"><i class="fas fa-save"></i> Save</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user