db username

This commit is contained in:
Usman Nasir
2020-07-16 22:30:29 +05:00
parent 041a3af678
commit c553c03253
4 changed files with 64 additions and 9 deletions

View File

@@ -215,6 +215,41 @@ class DatabaseManager:
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
def remoteAccess(self, userID = None, data = None):
try:
currentACL = ACLManager.loadedACL(userID)
if ACLManager.currentContextPermission(currentACL, 'listDatabases') == 0:
return ACLManager.loadErrorJson('changePasswordStatus', 0)
userName = data['dbUserName']
dbPassword = data['dbPassword']
db = Databases.objects.filter(dbUser=userName)
admin = Administrator.objects.get(pk=userID)
if ACLManager.checkOwnership(db[0].website.domain, admin, currentACL) == 1:
pass
else:
return ACLManager.loadErrorJson()
res = mysqlUtilities.changePassword(userName, dbPassword)
if res == 0:
data_ret = {'status': 0, 'changePasswordStatus': 0,'error_message': "Please see CyberPanel main log file."}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
data_ret = {'status': 1, 'changePasswordStatus': 1, 'error_message': "None"}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
except BaseException as msg:
data_ret = {'status': 0, 'changePasswordStatus': 0, 'error_message': str(msg)}
json_data = json.dumps(data_ret)
return HttpResponse(json_data)
@staticmethod
def generatePHPMYAdminData(userID):
try:

View File

@@ -454,7 +454,11 @@ app.controller('listDBs', function ($scope, $http) {
$scope.generatedPasswordView = true;
};
$scope.remoteAccess = function () {
$scope.remoteAccess = function (userName) {
$scope.dbUsername = userName;
alert($scope.dbUsername);
return 0;
$scope.dbLoading = false;
$scope.passwordChanged = true;

View File

@@ -119,7 +119,7 @@
class="btn ra-100 btn-purple">{% trans "Change" %}</button>
</td>
<td>
<button ng-click="remoteAccess()" data-toggle="modal"
<button ng-click="remoteAccess(record.dbUser)" data-toggle="modal"
data-target="#remoteAccess" type="button"
class="btn ra-100 btn-purple">{% trans "Manage" %}</button>
<div id="remoteAccess" class="modal fade" role="dialog">
@@ -137,19 +137,24 @@
</div>
<div class="modal-body">
<div class="form-group">
<label class="col-sm-12 control-label"
style="text-align: center;">{% trans "Contents of .gitignore, use the box below to Add/Edit content of .gitingore file." %}</label>
</div>
<hr>
<table style="margin-top: 2%" class="table">
<thead>
<tr>
<th>Type</th>
<th>Date</th>
<th>Message</th>
<th>Username</th>
<th>Host</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="log in logs track by $index">
<td ng-bind="log.type"></td>
<td ng-bind="log.date"></td>
<td ng-bind="log.message"></td>
<tr>
<td>{$ dbUsername $}</td>
<td></td>
</tr>
</tbody>
</table>

View File

@@ -120,6 +120,17 @@ def changePassword(request):
except KeyError:
return redirect(loadLoginPage)
def remoteAccess(request):
try:
userID = request.session['userID']
dm = DatabaseManager()
coreResult = dm.remoteAccess(userID, json.loads(request.body))
return coreResult
except KeyError:
return redirect(loadLoginPage)
def phpMyAdmin(request):
try:
userID = request.session['userID']