Show twofactor auth in setup wizard
This commit is contained in:
parent
f34d52fb65
commit
cde8001369
3 changed files with 44 additions and 1 deletions
|
|
@ -563,6 +563,36 @@ var frappe_slides = [
|
|||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
//Two Factor Select
|
||||
name:'twofactor',
|
||||
domains: ["all"],
|
||||
title: __("Two Factor Authentication"),
|
||||
icon: "fa fa-flag",
|
||||
help: __("Setup Two Factor Authentication For Users"),
|
||||
fields: [
|
||||
{ fieldname: "twofactor_enable", label: __("Enable Two Factor Authentication"),
|
||||
fieldtype: "Check"},
|
||||
{ fieldtype: "Section Break" },
|
||||
{ fieldname: "twofactor_method", label: __("Select Authentication Method"),
|
||||
fieldtype: "Select"}
|
||||
],
|
||||
onload:function(slide){
|
||||
slide.form.fields_dict.twofactor_method.df.options = ['SMS','Email','OTP App']
|
||||
slide.form.fields_dict.twofactor_method.$wrapper.css('display','none');
|
||||
slide.get_input('twofactor_enable').change(function(){
|
||||
slide.form.fields_dict.twofactor_method.$wrapper.toggle();
|
||||
if(this.checked){
|
||||
slide.form.fields_dict.twofactor_method.df.reqd = 1;
|
||||
}
|
||||
else{
|
||||
slide.form.fields_dict.twofactor_method.df.reqd = 0;
|
||||
}
|
||||
slide.form.fields_dict.twofactor_method.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
];
|
||||
|
||||
var utils = {
|
||||
|
|
|
|||
|
|
@ -76,8 +76,12 @@ def update_system_settings(args):
|
|||
'date_format': frappe.db.get_value("Country", args.get("country"), "date_format"),
|
||||
'number_format': number_format,
|
||||
'enable_scheduler': 1 if not frappe.flags.in_test else 0,
|
||||
'backup_limit': 3 # Default for downloadable backups
|
||||
'backup_limit': 3, # Default for downloadable backups
|
||||
'enable_two_factor_auth':args.get("twofactor_enable"),
|
||||
'two_factor_method':args.get('twofactor_method')
|
||||
})
|
||||
if args.get("twofactor_enable") == 1:
|
||||
enable_twofactor_all_roles()
|
||||
system_settings.save()
|
||||
|
||||
def update_user_name(args):
|
||||
|
|
@ -267,3 +271,10 @@ def email_setup_wizard_exception(traceback, args):
|
|||
|
||||
def get_language_code(lang):
|
||||
return frappe.db.get_value('Language', {'language_name':lang})
|
||||
|
||||
|
||||
def enable_twofactor_all_roles():
|
||||
all_role = frappe.get_doc('Role',{'role_name':'All'})
|
||||
all_role.two_factor_auth = True
|
||||
all_role.save(ignore_permissions=True)
|
||||
|
||||
|
|
|
|||
|
|
@ -190,3 +190,5 @@ bot_parsers = [
|
|||
|
||||
setup_wizard_exception = "frappe.desk.page.setup_wizard.setup_wizard.email_setup_wizard_exception"
|
||||
before_write_file = "frappe.limits.validate_space_limit"
|
||||
|
||||
otp_methods = ['OTP App','Email','SMS']
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue