Esempio n. 1
0
    def changePassword(self):
        try:
            userID = self.request.session['userID']
            currentACL = ACLManager.loadedACL(userID)

            if ACLManager.currentContextPermission(currentACL, 'listFTPAccounts') == 0:
                return ACLManager.loadErrorJson('changePasswordStatus', 0)

            data = json.loads(self.request.body)
            userName = data['ftpUserName']
            password = data['passwordByPass']

            admin = Administrator.objects.get(pk=userID)
            ftp = Users.objects.get(user=userName)

            if currentACL['admin'] == 1:
                pass
            elif ftp.domain.admin != admin:
                return ACLManager.loadErrorJson()

            FTPUtilities.changeFTPPassword(userName, password)

            data_ret = {'status': 1, 'changePasswordStatus': 1, 'error_message': "None"}
            json_data = json.dumps(data_ret)
            return HttpResponse(json_data)
        except BaseException, msg:
            data_ret = {'status': 0, 'changePasswordStatus': 0, 'error_message': str(msg)}
            json_data = json.dumps(data_ret)
            return HttpResponse(json_data)
Esempio n. 2
0
    def changeFTPPassword(self, userName, password):
        try:

            result = FTPUtilities.changeFTPPassword(userName, password)
            if result[0] == 1:
                self.printStatus(1, 'None')
            else:
                self.printStatus(1, result[1])
        except BaseException, msg:
            logger.writeforCLI(str(msg), "Error", stack()[0][3])
            self.printStatus(0, str(msg))
Esempio n. 3
0
    def changePassword(self):
        try:
            userID = self.request.session['userID']
            currentACL = ACLManager.loadedACL(userID)

            if ACLManager.currentContextPermission(currentACL, 'listFTPAccounts') == 0:
                return ACLManager.loadErrorJson('changePasswordStatus', 0)

            data = json.loads(self.request.body)
            userName = data['ftpUserName']
            password = data['ftpPassword']

            FTPUtilities.changeFTPPassword(userName, password)

            data_ret = {'status': 1, 'changePasswordStatus': 1, 'error_message': "None"}
            json_data = json.dumps(data_ret)
            return HttpResponse(json_data)
        except BaseException, msg:
            data_ret = {'status': 0, 'changePasswordStatus': 0, 'error_message': str(msg)}
            json_data = json.dumps(data_ret)
            return HttpResponse(json_data)
Esempio n. 4
0
def changePassword(request):
    try:
        val = request.session['userID']
        admin = Administrator.objects.get(id=val)
        try:
            if request.method == 'POST':

                data = json.loads(request.body)
                userName = data['ftpUserName']
                password = data['ftpPassword']

                ftp = Users.objects.get(user=userName)

                if admin.type != 1:
                    if ftp.domain.admin != admin:
                        data_ret = {
                            'changePasswordStatus': 0,
                            'error_message': 'Not enough privileges.'
                        }
                        json_data = json.dumps(data_ret)
                        return HttpResponse(json_data)

                FTPUtilities.changeFTPPassword(userName, password)

                data_ret = {'changePasswordStatus': 1, 'error_message': "None"}
                json_data = json.dumps(data_ret)
                return HttpResponse(json_data)

        except BaseException, msg:
            data_ret = {'changePasswordStatus': 0, 'error_message': str(msg)}
            json_data = json.dumps(data_ret)
            return HttpResponse(json_data)
    except KeyError, msg:
        data_ret = {'changePasswordStatus': 0, 'error_message': str(msg)}
        json_data = json.dumps(data_ret)
        return HttpResponse(json_data)