mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'bug/edit-user-issues' into 'dev'
Tweak Edit User Form See merge request crafty-controller/crafty-4!395
This commit is contained in:
commit
f3c09648f9
@ -9,8 +9,11 @@ None
|
||||
- Fix unhandled exeption when serverjars api returns 'None' ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/392))
|
||||
- Fix ajax issue with unzip on firefox ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/393))
|
||||
- Turn off verbose logging on Docker ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/394))
|
||||
- Refactor tempdir from packaging logs ([Commit](https://gitlab.com/crafty-controller/crafty-4/-/commit/f1d11bfb0d943c737ef2c4ef77bd0bfc9bcf83ba))
|
||||
### Tweaks
|
||||
None
|
||||
- Remove autofill on user form ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/395))
|
||||
- Confirm username does not exist on edituser ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/395))
|
||||
- Check for passwords matching on client side ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/395))
|
||||
### Lang
|
||||
- Add string "cloneConfirm" to german translation ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/389))
|
||||
<br><br>
|
||||
|
@ -100,6 +100,10 @@ class UsersController:
|
||||
def get_all_user_ids() -> t.List[int]:
|
||||
return HelperUsers.get_all_user_ids()
|
||||
|
||||
@staticmethod
|
||||
def get_all_usernames():
|
||||
return HelperUsers.get_all_usernames()
|
||||
|
||||
@staticmethod
|
||||
def get_id_by_name(username):
|
||||
return HelperUsers.get_user_id_by_name(username)
|
||||
|
@ -99,6 +99,14 @@ class HelperUsers:
|
||||
query = Users.select().where(Users.username != "system")
|
||||
return query
|
||||
|
||||
@staticmethod
|
||||
def get_all_usernames():
|
||||
usernames = []
|
||||
query = Users.select().where(Users.username != "system")
|
||||
for user in query:
|
||||
usernames.append(user.username)
|
||||
return usernames
|
||||
|
||||
@staticmethod
|
||||
def get_all_user_ids() -> t.List[int]:
|
||||
return [
|
||||
|
@ -1860,6 +1860,13 @@ class PanelHandler(BaseHandler):
|
||||
)
|
||||
user_id = bleach.clean(self.get_argument("id", None))
|
||||
username = bleach.clean(self.get_argument("username", None).lower())
|
||||
if (
|
||||
username != self.controller.users.get_user_by_id(user_id)["username"]
|
||||
and username in self.controller.users.get_all_usernames()
|
||||
):
|
||||
self.redirect(
|
||||
"/panel/error?error=Duplicate User: Useranme already exists."
|
||||
)
|
||||
password0 = bleach.clean(self.get_argument("password0", None))
|
||||
password1 = bleach.clean(self.get_argument("password1", None))
|
||||
email = bleach.clean(self.get_argument("email", "default@example.com"))
|
||||
|
@ -75,29 +75,35 @@
|
||||
<label class="form-label" for="username">{{ translate('userConfig', 'userName', data['lang'])
|
||||
}}<small class="text-muted ml-1"> - {{ translate('userConfig', 'userNameDesc', data['lang'])
|
||||
}}</small> </label>
|
||||
<input type="text" class="form-control" name="username" id="username"
|
||||
value="{{ data['user']['username'] }}" placeholder="User Name">
|
||||
<input type="text" class="form-control" name="username" id="username" autocomplete="off"
|
||||
data-lpignore="true" value="{{ data['user']['username'] }}" placeholder="User Name">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="password0">{{ translate('userConfig', 'password', data['lang'])
|
||||
}}<small class="text-muted ml-1"> - {{ translate('userConfig', 'leaveBlank', data['lang']) }}
|
||||
</small> </label>
|
||||
<input type="password" class="form-control" name="password0" id="password0" value=""
|
||||
placeholder="Password">
|
||||
autocomplete="new-password" data-lpignore="true" placeholder="Password">
|
||||
<span class="passwords-match" ,
|
||||
data-content="{{ translate('panelConfig', 'match', data['lang']) }}" ,
|
||||
data-placement="right"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="password1">{{ translate('userConfig', 'repeat', data['lang']) }}
|
||||
<small class="text-muted ml-1"> - {{ translate('userConfig', 'leaveBlank', data['lang'])
|
||||
}}</small> </label>
|
||||
<input type="password" class="form-control" name="password1" id="password1" value=""
|
||||
placeholder="Repeat Password">
|
||||
autocomplete="new-password" data-lpignore="true" placeholder="Repeat Password">
|
||||
<span class="passwords-match" ,
|
||||
data-content="{{ translate('panelConfig', 'match', data['lang']) }}" ,
|
||||
data-placement="right"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="email">{{ translate('userConfig', 'gravEmail', data['lang'])
|
||||
}}<small class="text-muted ml-1"> - {{ translate('userConfig', 'gravDesc', data['lang'])
|
||||
}}</small> </label>
|
||||
<input type="email" class="form-control" name="email" id="email"
|
||||
value="{{ data['user']['email'] }}" placeholder="Gravatar Email">
|
||||
<input type="email" class="form-control" name="email" id="email" autocomplete="off"
|
||||
data-lpignore="true" value="{{ data['user']['email'] }}" placeholder="Gravatar Email">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="language">{{ translate('userConfig', 'userLang', data['lang'])
|
||||
@ -237,7 +243,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-success mr-2"><i class="fas fa-save"></i> {{
|
||||
<button class="btn btn-success mr-2" onclick="submit_user(event);"><i class="fas fa-save"></i> {{
|
||||
translate('panelConfig', 'save', data['lang']) }}</button>
|
||||
<button type="reset" onclick="location.href='/panel/panel_config'" class="btn btn-light"><i
|
||||
class="fas fa-undo-alt"></i> {{ translate('panelConfig', 'cancel', data['lang']) }}</button>
|
||||
@ -290,12 +296,43 @@
|
||||
|
||||
|
||||
</div>
|
||||
<style>
|
||||
.popover-body {
|
||||
color: white !important;
|
||||
outline: 1px solid red !important;
|
||||
;
|
||||
}
|
||||
</style>
|
||||
<!-- content-wrapper ends -->
|
||||
|
||||
{% end %}
|
||||
|
||||
{% block js %}
|
||||
<script>
|
||||
function submit_user(event) {
|
||||
if (!validateForm()) {
|
||||
event.preventDefault();
|
||||
} else {
|
||||
$('#userForm').submit();
|
||||
}
|
||||
}
|
||||
function validateForm() {
|
||||
let password0 = document.getElementById("password0").value
|
||||
let password1 = document.getElementById("password1").value
|
||||
if (password0 != password1) {
|
||||
$('.passwords-match').popover('show');
|
||||
$('.popover-body').click(function () {
|
||||
$('.passwords-match').popover("hide");
|
||||
});
|
||||
document.body.scrollTop = 0;
|
||||
document.documentElement.scrollTop = 0;
|
||||
$("#password0").css("outline", "1px solid red");
|
||||
$("#password1").css("outline", "1px solid red");
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
const userId = new URLSearchParams(document.location.search).get('id')
|
||||
|
||||
$(".delete-user").click(function () {
|
||||
|
@ -220,7 +220,8 @@
|
||||
"superConfirm": "Proceed only if you want this user to have access to EVERYTHING (all user accounts, servers, panel settings, etc.). They can even revoke your superuser rights.",
|
||||
"superConfirmTitle": "Enable superuser? Are you sure?",
|
||||
"user": "User",
|
||||
"users": "Users"
|
||||
"users": "Users",
|
||||
"match": "Passwords must match"
|
||||
},
|
||||
"rolesConfig": {
|
||||
"config": "Role Config",
|
||||
|
Loading…
Reference in New Issue
Block a user