Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1079 disallow empty password #1105

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions web/dashboard/templates/dashboard/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ <h4>Users</h4>
var create_username = document.getElementById('create_username').value;
var role_selected = document.getElementById('create_user_role').value;
var create_password = document.getElementById('create_password').value;
if (!create_password) {
Swal.fire({
title: "Oops! Passwords can't be empty!",
icon: 'error',
})
return
}
const data = {
'username': create_username,
'role': role_selected,
Expand Down
7 changes: 5 additions & 2 deletions web/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ def admin_interface_update(request, slug):
try:
user.delete()
messages.add_message(
request,
messages.INFO,
request,
messages.INFO,
f'User {user.username} successfully deleted.'
)
messageData = {'status': True}
Expand All @@ -245,6 +245,9 @@ def admin_interface_update(request, slug):
elif mode == 'create':
try:
response = json.loads(request.body)
if not response.get('password'):
messageData = {'status': False, 'error': 'Empty passwords are not allowed'}
return JsonResponse(messageData)
UserModel = get_user_model()
user = UserModel.objects.create_user(
username=response.get('username'),
Expand Down
Loading