Skip to content

Commit

Permalink
Merge pull request #1105 from yogeshojha/1079-disallow-empty-password
Browse files Browse the repository at this point in the history
1079 disallow empty password
  • Loading branch information
AnonymousWP authored Dec 5, 2023
2 parents e9771c5 + 26d9c23 commit 5cc63b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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

0 comments on commit 5cc63b1

Please sign in to comment.