def clearSession(self, uid): session = yield self.getSession(uid) authInfo = session.getComponent(IAuthInfo) userId = authInfo.username orgId = authInfo.organization yield db.remove(uid, "sessions", "auth") yield db.remove(userId, "userSessionsMap", uid) yield utils.cleanupChat(uid, userId, orgId)
def disconnect(self, request): sessionId = utils.getRequestArg(request, "sessionid", sanitize=False) try: session = yield defer.maybeDeferred(request.site.getSession, sessionId) except ttypes.NotFoundException: raise errors.NotFoundError() userId = session.getComponent(IAuthInfo).username orgId = session.getComponent(IAuthInfo).organization yield utils.cleanupChat(sessionId, userId, orgId) self._success(request, 200, {})
def _blockUser(self, request, data=None): authInfo = request.getSession(IAuthInfo) myId = authInfo.username orgId = authInfo.organization user = data['id'] # Admin cannot block himself. if user.id == myId: raise errors.InvalidRequest(_("You cannot block yourself.")) emailId = user.basic.get("emailId", None) yield db.insert(emailId, "userAuth", 'True', "isBlocked") yield db.insert(orgId, "blockedUsers", '', user.id) sessionIds = yield db.get_slice(user.id, "userSessionsMap") sessionIds = utils.columnsToDict(sessionIds) for sessionId in sessionIds: yield db.remove(sessionId, "sessions") yield utils.cleanupChat(sessionId, user.id, orgId) yield db.remove(user.id, "userSessionsMap") t.renderScriptBlock(request, "admin.mako", "admin_actions", False, "#user-actions-%s" % (user.id), "set", args=[user.id, 'blocked'])