예제 #1
0
def resetPassword(request, enc_username):
    username = decrypt(enc_username)
    try:
        userObj = User.objects.get(username=username)
    except ObjectDoesNotExist:
        raise Http404

    if request.method == 'POST':
        password1 = request.POST.get('password1')
        password2 = request.POST.get('password2')

        if password1 != password2:
            return HttpResponse(
                "Password and Confirm Password are not matching!!!")

        userObj.set_password(password1)
        userObj.save()
        return HttpResponse(
            "Your password reset successfully, <a href='%s'>Go To Login</a>" %
            reverse('login'))

    return render(request, 'resetPassword.html', {'username': username})
예제 #2
0
        # utils.log(utils.cur(), "db forbidden", is_legal)
        """
        2. find /DB_INFO/database node and retrieve DB_PASS, DB_USER, DB_DB
        """
        try:
            if is_legal:
                dbpath = os.path.join(ZKConf.ZK_PATH_DB, auth["database"], ZKConf.KEY_DBCONF)
                is_legal = self.factory.get_path(dbpath)
                if is_legal is not False:
                    is_legal = True
                    info = {"passwd": "", "user": "", "database":""}
                    info["passwd"]   = self.factory.get_path(dbpath + "/" + ZKConf.KEY_PASSWORD)
                    info["user"]     = self.factory.get_path(dbpath + "/" + ZKConf.KEY_USER)
                    info["database"] = auth["database"]
                    info["passwd"] = utils.mysqlsha1(utils.decrypt(info["passwd"]))
        except Exception, err:
            utils.err(utils.cur(), err)
            is_legal = False

        # utils.log(utils.cur(), "path existed", is_legal)
        """
        3. check whether there is password
        """
        if is_legal and not auth["scramble_buff"]: is_legal = False
        # utils.log(utils.cur(), "passwd has", is_legal)
        """
        4. check whether password is correct
        """
        if is_legal:
            for k in info:
예제 #3
0
파일: listen.py 프로젝트: fifar/mysql_proxy
                def cb(pro, db):
                    if callable(callback):
                        proObj.server = pro.factory.servers.pop(db)
                        self.busy_proobj[db].append(proObj)
                        callback(proObj)

                dbinfo = {"host_r": "", "host_w": "", "user": "", "passwd": "", "dbshow": db, "db": ""}

                path_host_r = os.path.join(dbpath, ZKConf.KEY_READ)
                path_host_w = os.path.join(dbpath, ZKConf.KEY_WRITE)
                path_pass = os.path.join(dbpath, ZKConf.KEY_PASSWORD)
                path_user = os.path.join(dbpath, ZKConf.KEY_USER)
                path_db = os.path.join(dbpath, ZKConf.KEY_DB)
                dbinfo["host_r"] = self.zk.get(path_host_r, None)[0]
                dbinfo["host_w"] = self.zk.get(path_host_w, None)[0]
                dbinfo["passwd"] = utils.decrypt(self.zk.get(path_pass, None)[0])
                dbinfo["user"] = self.zk.get(path_user, None)[0]
                dbinfo["db"] = self.zk.get(path_db, None)[0]
                utils.log(utils.cur(), path_host_r, path_host_w)
                RWClient(dbinfo, proObj, cb)

            else:
                raise Exception("MySQL has gone away, f_f")

    def takeServer(self, server, proObj):
        if server and hasattr(server, "ready") and server.ready == 2:
            # clean SQL cache
            server.raw_sql_clear()
            db = server.getDB()
            stats_conns.decr(db)
            try:
예제 #4
0
파일: listen.py 프로젝트: yucz/mysql_proxy
                    "host_r" : "",
                    "host_w" : "",
                    "user"   : "",
                    "passwd" : "",
                    "dbshow" : db,
                    "db" : "",
                    }
                
                path_host_r = os.path.join(dbpath, ZKConf.KEY_READ)
                path_host_w = os.path.join(dbpath, ZKConf.KEY_WRITE)
                path_pass   = os.path.join(dbpath, ZKConf.KEY_PASSWORD)
                path_user   = os.path.join(dbpath, ZKConf.KEY_USER)
                path_db     = os.path.join(dbpath, ZKConf.KEY_DB)
                dbinfo["host_r"] = self.zk.get(path_host_r, None)[0]
                dbinfo["host_w"] = self.zk.get(path_host_w, None)[0]
                dbinfo["passwd"] = utils.decrypt(self.zk.get(path_pass, None)[0])
                dbinfo["user"] = self.zk.get(path_user, None)[0]
                dbinfo["db"] = self.zk.get(path_db, None)[0]
                utils.log(utils.cur(), path_host_r, path_host_w)
                RWClient(dbinfo, proObj, cb)

            else:
                raise Exception("MySQL has gone away, f_f")
    
    def takeServer(self, server, proObj):
        if server and hasattr(server, "ready") and server.ready == 2:
            # clean SQL cache
            server.raw_sql_clear()
            db = server.getDB()
            stats_conns.decr(db)
            try: