MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / ResDatabasePassword

Method ResDatabasePassword

class/databaseModel/sqlserverModel.py:352–378  ·  view source on GitHub ↗

@修改用户密码

(self, args)

Source from the content-addressed store, hash-verified

350 return public.returnMsg(True, 'DATABASE_GET_SUCCESS', (str(n),))
351
352 def ResDatabasePassword(self, args):
353 """
354 @修改用户密码
355 """
356 id = args['id']
357 username = args['name'].strip()
358 newpassword = public.trim(args['password'])
359
360 try:
361 if not newpassword:
362 return public.returnMsg(False, '修改失败,数据库[' + username + ']密码不能为空.')
363 if len(re.search("^[\w@\.]+$", newpassword).groups()) > 0:
364 return public.returnMsg(False, '数据库密码不能为空或带有特殊字符')
365 except:
366 return public.returnMsg(False, '数据库密码不能为空或带有特殊字符')
367
368 find = public.M('databases').where("id=? AND LOWER(type)=LOWER('SQLServer')", (id,)).field('id,pid,name,username,password,type,accept,ps,addtime,sid').find()
369 if not find: return public.returnMsg(False, '修改失败,指定数据库不存在.')
370
371 mssql_obj = self.get_mssql_obj_by_sid(find['sid'])
372 mssql_obj.execute("EXEC sp_password NULL, '%s', '%s'" % (newpassword, username))
373
374 # 修改SQLITE
375 public.M('databases').where("id=? AND LOWER(type)=LOWER('SQLServer')", (id,)).setField('password', newpassword)
376
377 public.WriteLog("TYPE_DATABASE", 'DATABASE_PASS_SUCCESS', (find['name'],))
378 return public.returnMsg(True, 'DATABASE_PASS_SUCCESS', (find['name'],))
379
380 def get_root_pwd(self, args):
381 """

Callers

nothing calls this directly

Calls 10

get_mssql_obj_by_sidMethod · 0.95
returnMsgMethod · 0.80
trimMethod · 0.45
searchMethod · 0.45
findMethod · 0.45
fieldMethod · 0.45
whereMethod · 0.45
MMethod · 0.45
executeMethod · 0.45
setFieldMethod · 0.45

Tested by

no test coverage detected