Improved login errors,
Added user disable option, Fix groups selection in tasks, Improved Auto updater, Fixed sorting of scan reports, Some pro feature
This commit is contained in:
parent
c39721de96
commit
30d60a72ad
12 changed files with 115 additions and 38 deletions
|
|
@ -11,7 +11,7 @@ from libs.util import ISPRO
|
|||
from libs.db import db,db_permissions,db_user_group_perm,db_groups,db_sysconfig,db_syslog
|
||||
|
||||
import json
|
||||
from libs import webutil,account
|
||||
from libs import utilpro, webutil,account
|
||||
from libs.webutil import app, login_required, get_myself , buildResponse
|
||||
from libs.mschap3.mschap import nt_password_hash
|
||||
|
||||
|
|
@ -29,19 +29,18 @@ def login():
|
|||
password = input.get('password')
|
||||
|
||||
if not username or not password:
|
||||
return webutil.warn_reply("Missing input")
|
||||
return buildResponse({"status":"failed", "err":"Wrong user/pass"}, 200)
|
||||
|
||||
u = db.get_user_by_username(username)
|
||||
if not u or not account.check_password(u.password, password):
|
||||
if not u or not account.check_password(u.password, password) or u.role=='disabled':
|
||||
# error
|
||||
try:
|
||||
db_syslog.add_syslog_event(u.id, "User login","Failed login",webutil.get_ip(),webutil.get_agent(),json.dumps({"username":username}))
|
||||
db_syslog.add_syslog_event(u.id, "User login","Failed login",webutil.get_ip(),webutil.get_agent(),json.dumps({"username":username,'reason':'wrong password'}))
|
||||
except:
|
||||
pass
|
||||
return webutil.warn_reply("Invalid login credentials")
|
||||
return buildResponse({"status":"failed", "err":"Wrong user/pass"}, 200)
|
||||
else:
|
||||
# success
|
||||
account.build_session(u, is_permanent=input.get('remember', True))
|
||||
tz=db_sysconfig.get_sysconfig('timezone')
|
||||
# log.info("LOGIN OK agent={}".format(webutil.get_agent()))
|
||||
res={
|
||||
|
|
@ -56,6 +55,11 @@ def login():
|
|||
"tz":tz,
|
||||
"perms":json.loads(u.adminperms)
|
||||
}
|
||||
if ISPRO:
|
||||
prores=utilpro.do_login(res,input)
|
||||
if prores:
|
||||
return buildResponse(prores, 200)
|
||||
account.build_session(u, is_permanent=input.get('remember', True))
|
||||
db_syslog.add_syslog_event(u.id, "User login","Successful login",webutil.get_ip(),webutil.get_agent(),json.dumps({"username":username}))
|
||||
return buildResponse(res, 200)
|
||||
|
||||
|
|
@ -248,7 +252,7 @@ def user_edit():
|
|||
if lname:
|
||||
u.last_name = lname
|
||||
|
||||
if role:
|
||||
if role and str(u.id) != "37cc36e0-afec-4545-9219-94655805868b":
|
||||
u.role = role
|
||||
if adminperms and str(u.id) != "37cc36e0-afec-4545-9219-94655805868b":
|
||||
u.adminperms= json.dumps(adminperms)
|
||||
|
|
|
|||
|
|
@ -77,7 +77,10 @@ def get_editform():
|
|||
if not dev:
|
||||
return buildResponse({'status': 'failed'}, 200, error="Wrong Data")
|
||||
res['user_name']=util.decrypt_data(dev['user_name'])
|
||||
res['password']=util.decrypt_data(dev['password'])
|
||||
if ISPRO:
|
||||
res['password']="Password is Hidden"
|
||||
else:
|
||||
res['password']=util.decrypt_data(dev['password'])
|
||||
res['ip']=dev['ip']
|
||||
res['peer_ip']=dev['peer_ip']
|
||||
res['name']=dev['name']
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ def scan_resutls():
|
|||
input = request.json
|
||||
tasks=db_tasks.TaskResults
|
||||
#Get tasks that is task_type is ip-scan
|
||||
tasks=tasks.select().where(tasks.task_type=='ip-scan')
|
||||
tasks=tasks.select().where(tasks.task_type=='ip-scan').order_by(tasks.id.desc())
|
||||
tasks=list(tasks.dicts())
|
||||
#Get task results
|
||||
return buildResponse({'status': True,'data':tasks},200)
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ def user_tasks_list():
|
|||
clauses.append(utaks.task_type == task_type)
|
||||
if not ISPRO:
|
||||
clauses.append(utaks.task_type != 'firmware')
|
||||
clauses.append(utaks.task_type != 'vault')
|
||||
clauses.append(utaks.task_type != 'snipet_exec')
|
||||
expr=""
|
||||
logs = []
|
||||
|
|
@ -89,7 +90,7 @@ def user_tasks_create():
|
|||
data={
|
||||
'name':name,
|
||||
'description':description,
|
||||
'snippetid':int(snippetid) if snippetid else 0,
|
||||
'snippetid':int(snippetid) if snippetid else None,
|
||||
'cron':cron,
|
||||
'desc_cron': get_description(cron),
|
||||
'action': action,
|
||||
|
|
@ -163,7 +164,7 @@ def user_tasks_edit():
|
|||
data={
|
||||
'name':name,
|
||||
'description':description,
|
||||
'snippetid':int(snippetid) if snippetid else 0,
|
||||
'snippetid':int(snippetid) if snippetid else None,
|
||||
'cron':cron,
|
||||
'desc_cron': get_description(cron),
|
||||
'action': action,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue