mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Delete pushers when changing password
This commit is contained in:
parent
df4c12c762
commit
a32e876ef4
@ -70,4 +70,7 @@ class LoginHandler(BaseHandler):
|
||||
|
||||
yield self.store.user_set_password_hash(user_id, password_hash)
|
||||
yield self.store.user_delete_access_tokens_apart_from(user_id, token_id)
|
||||
yield self.hs.get_pusherpool().remove_pushers_by_user_access_token(
|
||||
user_id, token_id
|
||||
)
|
||||
yield self.store.flush_user(user_id)
|
||||
|
@ -71,7 +71,7 @@ class PusherPool:
|
||||
"app_display_name": app_display_name,
|
||||
"device_display_name": device_display_name,
|
||||
"pushkey": pushkey,
|
||||
"pushkey_ts": self.hs.get_clock().time_msec(),
|
||||
"ts": self.hs.get_clock().time_msec(),
|
||||
"lang": lang,
|
||||
"data": data,
|
||||
"last_token": None,
|
||||
@ -98,6 +98,22 @@ class PusherPool:
|
||||
)
|
||||
self.remove_pusher(p['app_id'], p['pushkey'], p['user_name'])
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def remove_pushers_by_user_access_token(self, user_id, not_access_token_id):
|
||||
all = yield self.store.get_all_pushers()
|
||||
logger.info(
|
||||
"Removing all pushers for user %s except access token %s",
|
||||
user_id, not_access_token_id
|
||||
)
|
||||
for p in all:
|
||||
if (p['user_name'] == user_id and
|
||||
p['access_token'] != not_access_token_id):
|
||||
logger.info(
|
||||
"Removing pusher for app id %s, pushkey %s, user %s",
|
||||
p['app_id'], p['pushkey'], p['user_name']
|
||||
)
|
||||
self.remove_pusher(p['app_id'], p['pushkey'], p['user_name'])
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _add_pusher_to_store(self, user_name, access_token, profile_tag, kind,
|
||||
app_id, app_display_name, device_display_name,
|
||||
@ -127,7 +143,7 @@ class PusherPool:
|
||||
app_display_name=pusherdict['app_display_name'],
|
||||
device_display_name=pusherdict['device_display_name'],
|
||||
pushkey=pusherdict['pushkey'],
|
||||
pushkey_ts=pusherdict['pushkey_ts'],
|
||||
pushkey_ts=pusherdict['ts'],
|
||||
data=pusherdict['data'],
|
||||
last_token=pusherdict['last_token'],
|
||||
last_success=pusherdict['last_success'],
|
||||
|
@ -28,11 +28,9 @@ logger = logging.getLogger(__name__)
|
||||
class PusherStore(SQLBaseStore):
|
||||
@defer.inlineCallbacks
|
||||
def get_pushers_by_app_id_and_pushkey(self, app_id, pushkey):
|
||||
cols = ",".join(PushersTable.fields)
|
||||
sql = (
|
||||
"SELECT id, user_name, kind, profile_tag, app_id,"
|
||||
"app_display_name, device_display_name, pushkey, ts, data, "
|
||||
"last_token, last_success, failing_since "
|
||||
"FROM pushers "
|
||||
"SELECT "+cols+" FROM pushers "
|
||||
"WHERE app_id = ? AND pushkey = ?"
|
||||
)
|
||||
|
||||
@ -43,51 +41,26 @@ class PusherStore(SQLBaseStore):
|
||||
|
||||
ret = [
|
||||
{
|
||||
"id": r[0],
|
||||
"user_name": r[1],
|
||||
"kind": r[2],
|
||||
"profile_tag": r[3],
|
||||
"app_id": r[4],
|
||||
"app_display_name": r[5],
|
||||
"device_display_name": r[6],
|
||||
"pushkey": r[7],
|
||||
"pushkey_ts": r[8],
|
||||
"data": r[9],
|
||||
"last_token": r[10],
|
||||
"last_success": r[11],
|
||||
"failing_since": r[12]
|
||||
k: r[i] for i, k in enumerate(PushersTable.fields)
|
||||
}
|
||||
for r in rows
|
||||
]
|
||||
print ret
|
||||
|
||||
defer.returnValue(ret)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def get_all_pushers(self):
|
||||
cols = ",".join(PushersTable.fields)
|
||||
sql = (
|
||||
"SELECT id, user_name, kind, profile_tag, app_id,"
|
||||
"app_display_name, device_display_name, pushkey, ts, data, "
|
||||
"last_token, last_success, failing_since "
|
||||
"FROM pushers"
|
||||
"SELECT "+cols+" FROM pushers"
|
||||
)
|
||||
|
||||
rows = yield self._execute("get_all_pushers", None, sql)
|
||||
|
||||
ret = [
|
||||
{
|
||||
"id": r[0],
|
||||
"user_name": r[1],
|
||||
"kind": r[2],
|
||||
"profile_tag": r[3],
|
||||
"app_id": r[4],
|
||||
"app_display_name": r[5],
|
||||
"device_display_name": r[6],
|
||||
"pushkey": r[7],
|
||||
"pushkey_ts": r[8],
|
||||
"data": r[9],
|
||||
"last_token": r[10],
|
||||
"last_success": r[11],
|
||||
"failing_since": r[12]
|
||||
k: r[i] for i, k in enumerate(PushersTable.fields)
|
||||
}
|
||||
for r in rows
|
||||
]
|
||||
@ -166,13 +139,15 @@ class PushersTable(Table):
|
||||
fields = [
|
||||
"id",
|
||||
"user_name",
|
||||
"access_token",
|
||||
"kind",
|
||||
"profile_tag",
|
||||
"app_id",
|
||||
"app_display_name",
|
||||
"device_display_name",
|
||||
"pushkey",
|
||||
"pushkey_ts",
|
||||
"ts",
|
||||
"lang",
|
||||
"data",
|
||||
"last_token",
|
||||
"last_success",
|
||||
|
Loading…
Reference in New Issue
Block a user