Add Password Generator

Add CIDR Netmasks
This commit is contained in:
David Malinowski 2021-03-29 15:19:44 +02:00
parent 5111280392
commit 7374e1a6b5
4 changed files with 23 additions and 3 deletions

View File

@ -46,7 +46,7 @@
"fieldtype": "Select", "fieldtype": "Select",
"in_list_view": 1, "in_list_view": 1,
"label": "CIDR Mask", "label": "CIDR Mask",
"options": "24\n25\n26\n27\n28\n29\n30\n31\n32", "options": "24\n16\n12\n8\n32\n31\n30\n29\n28\n27\n26\n25\n23\n22\n21\n20\n19\n18\n17\n15\n14\n13\n11\n10\n9\n7\n6\n5\n4\n3\n2\n1",
"reqd": 1 "reqd": 1
}, },
{ {
@ -147,7 +147,7 @@
"label": "Aditional Data" "label": "Aditional Data"
} }
], ],
"modified": "2021-03-24 00:12:13.023565", "modified": "2021-03-29 15:19:10.791248",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "MSP", "module": "MSP",
"name": "IP Network", "name": "IP Network",

View File

@ -4,6 +4,7 @@
frappe.ui.form.on('IT User Account', { frappe.ui.form.on('IT User Account', {
refresh: function(frm) { refresh: function(frm) {
frm.add_custom_button('Copy PW', () => frm.trigger('get_pw')); frm.add_custom_button('Copy PW', () => frm.trigger('get_pw'));
frm.add_custom_button('Generate PW', () => frm.trigger('generate_new_pw'));
}, },
get_pw: function(frm) { get_pw: function(frm) {
@ -15,6 +16,16 @@ frappe.ui.form.on('IT User Account', {
frm.events.CopyToClipboard(r.message) frm.events.CopyToClipboard(r.message)
} }
); );
},
generate_new_pw: function(frm) {
frm.call('generate_new_pw', {
},
(r) => {
frm.events.CopyToClipboard(r.message);
frm.set_value()("password", r.message);
frm.save()
}
);
}, },
CopyToClipboard: function(value) { CopyToClipboard: function(value) {
var tempInput = document.createElement("input"); var tempInput = document.createElement("input");

View File

@ -5,6 +5,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document
from passwordgenerator import pwgenerator
class ITUserAccount(Document): class ITUserAccount(Document):
@ -23,3 +24,10 @@ class ITUserAccount(Document):
self.save() self.save()
""" """
return(self.get_password("password")) return(self.get_password("password"))
@frappe.whitelist()
def generate_new_pw(self):
new_password = pwgenerator.generate()
print(new_password)
return(new_password)

View File

@ -1,2 +1,3 @@
frappe frappe
ipaddress ipaddress
passwordgenerator