def newAuth(self, dic, userDic, user): authDic = {} authDic["user"] = dic["email"] authDic["auth_token"] = self.helperHandler.id_generator(size=45) authDic["refresh_token"] = self.helperHandler.id_generator(size=45) authDic["expires_at"] = "" auth = Auth() auth.dictToAuth(authDic) self.authDao.deleteAuth(auth) res = self.authDao.insertAuth(auth) data = auth.authToDict() # fix userAuth as well userDic["authorized"] = "1" user.dictToUser(userDic) self.userDao.updateUser(user) return json.dumps({"success": res[0], "data": data})