def post(self, client_id): self._require_login() self._require_registration() # Check to make sure the user isn't trying to impersonate another current_user_account_id = self.user_bundle.account.key.id() target_account_id = self.request.get('account_id') if target_account_id == current_user_account_id: verification = self.request.get('code') webhook = MobileClient.get_by_id(int(client_id), parent=ndb.Key( Account, current_user_account_id)) if webhook.client_type == ClientType.WEBHOOK and current_user_account_id == webhook.user_id: if verification == webhook.verification_code: logging.info("webhook verified") webhook.verified = True webhook.put() self.redirect('/account?webhook_verification_success=1') return else: # Verification failed # Redirect back to the verification page self.redirect('/webhooks/verify/{}?error=1'.format( webhook.key.id())) return self.redirect('/')
def post(self): self._require_login() self._require_registration() # Check to make sure that they aren't trying to edit another user current_user_account_id = self.user_bundle.account.key.id() target_account_id = self.request.get('account_id') if target_account_id == current_user_account_id: client_id = self.request.get('client_id') client = MobileClient.get_by_id(int(client_id), parent=ndb.Key( Account, current_user_account_id)) if client is not None: # This makes sure that the client actually exists and that this user owns it if client.client_type == ClientType.WEBHOOK: keys = { client.client_type: [(client.messaging_id, client.secret)] } else: keys = {client.client_type: [client.messaging_id]} notification = PingNotification() notification.send(keys) self.redirect('/account') else: self.redirect('/')
def post(self): self._require_login() self._require_registration() current_user_account_id = self.user_bundle.account.key.id() target_account_id = self.request.get('account_id') if target_account_id == current_user_account_id: client_id = self.request.get('client_id') webhook = MobileClient.get_by_id(int(client_id), parent=ndb.Key( Account, current_user_account_id)) if webhook.client_type == ClientType.WEBHOOK and current_user_account_id == webhook.user_id: verification_key = NotificationHelper.verify_webhook( webhook.messaging_id, webhook.secret) webhook.verification_code = verification_key webhook.verified = False webhook.put() self.redirect('/account') return else: logging.warning("Not webhook, or wrong owner") else: logging.warning("Users don't match. " + current_user_account_id + "/" + target_account_id) self.redirect('/')
def post(self): self._require_registration() # Check to make sure that they aren't trying to edit another user current_user_account_id = self.user_bundle.account.key.id() target_account_id = self.request.get('account_id') if target_account_id == current_user_account_id: client_id = self.request.get('client_id') client = MobileClient.get_by_id(int(client_id), parent=ndb.Key(Account, current_user_account_id)) if client is not None: # This makes sure that the client actually exists and that this user owns it NotificationHelper.send_ping(client) return self.redirect('/account?ping_sent=1') self.redirect('/')
def post(self): self._require_registration() # Check to make sure that they aren't trying to edit another user current_user_account_id = self.user_bundle.account.key.id() target_account_id = self.request.get('account_id') if target_account_id == current_user_account_id: client_id = self.request.get('client_id') client = MobileClient.get_by_id(int(client_id), parent=ndb.Key( Account, current_user_account_id)) if client is not None: # This makes sure that the client actually exists and that this user owns it NotificationHelper.send_ping(client) return self.redirect('/account?ping_sent=1') self.redirect('/')
def post(self): self._require_registration() # Check to make sure that they aren't trying to edit another user current_user_account_id = self.user_bundle.account.key.id() target_account_id = self.request.get('account_id') if target_account_id == current_user_account_id: client_id = self.request.get('client_id') client = MobileClient.get_by_id(int(client_id), parent=ndb.Key(Account, current_user_account_id)) if client is not None: # This makes sure that the client actually exists and that this user owns it if client.client_type == ClientType.WEBHOOK: keys = {client.client_type: [(client.messaging_id, client.secret)]} else: keys = {client.client_type: [client.messaging_id]} notification = PingNotification() notification.send(keys) self.redirect('/account') else: self.redirect('/')
def post(self): self._require_registration() current_user_account_id = self.user_bundle.account.key.id() target_account_id = self.request.get('account_id') if target_account_id == current_user_account_id: client_id = self.request.get('client_id') webhook = MobileClient.get_by_id(int(client_id), parent=ndb.Key(Account, current_user_account_id)) if webhook.client_type == ClientType.WEBHOOK and current_user_account_id == webhook.user_id: verification_key = NotificationHelper.verify_webhook(webhook.messaging_id, webhook.secret) webhook.verification_code = verification_key webhook.verified = False webhook.put() self.redirect('/account') return else: logging.warning("Not webhook, or wrong owner") else: logging.warning("Users don't match. "+current_user_account_id+"/"+target_account_id) self.redirect('/')
def post(self, client_id): self._require_registration() # Check to make sure the user isn't trying to impersonate another current_user_account_id = self.user_bundle.account.key.id() target_account_id = self.request.get('account_id') if target_account_id == current_user_account_id: verification = self.request.get('code') webhook = MobileClient.get_by_id(int(client_id), parent=ndb.Key(Account, current_user_account_id)) if webhook.client_type == ClientType.WEBHOOK and current_user_account_id == webhook.user_id: if verification == webhook.verification_code: logging.info("webhook verified") webhook.verified = True webhook.put() self.redirect('/account?webhook_verification_success=1') return else: # Verification failed # Redirect back to the verification page self.redirect('/webhooks/verify/{}?error=1'.format(webhook.key.id())) return self.redirect('/')
def post(self): self._require_registration() # Check to make sure that they aren't trying to edit another user current_user_account_id = self.user_bundle.account.key.id() target_account_id = self.request.get('account_id') if target_account_id == current_user_account_id: client_id = self.request.get('client_id') client = MobileClient.get_by_id(int(client_id), parent=ndb.Key( Account, current_user_account_id)) if client is not None: from helpers.tbans_helper import TBANSHelper success = TBANSHelper.ping(client) if success: return self.redirect('/account?ping_sent=1') else: return self.redirect('/account?ping_sent=0') self.redirect('/')
def post(self, client_id): self._require_registration() self._require_request_user_is_bundle_user() current_user_account_id = self.user_bundle.account.key.id() if not current_user_account_id: return self.redirect('/') verification = self.request.get('code') if not verification: return self.redirect('/webhooks/verify/{}?error=1'.format(webhook.key.id())) webhook = MobileClient.get_by_id(int(client_id), parent=ndb.Key(Account, current_user_account_id)) if not webhook or webhook.client_type != ClientType.WEBHOOK or current_user_account_id != webhook.user_id: return self.redirect('/') if verification == webhook.verification_code: webhook.verified = True webhook.put() return self.redirect('/account?webhook_verification_success=1') else: # Redirect back to the verification page return self.redirect('/webhooks/verify/{}?error=1'.format(webhook.key.id()))
def post(self): self._require_registration() self._require_request_user_is_bundle_user() current_user_account_id = self.user_bundle.account.key.id() if not current_user_account_id: return self.redirect('/') client_id = self.request.get('client_id') if not client_id: return self.redirect('/') webhook = MobileClient.get_by_id(int(client_id), parent=ndb.Key(Account, current_user_account_id)) if not webhook or webhook.client_type != ClientType.WEBHOOK or current_user_account_id != webhook.user_id: return self.redirect('/') from helpers.tbans_helper import TBANSHelper verification_key = TBANSHelper.verify_webhook(webhook.messaging_id, webhook.secret) webhook.verification_code = verification_key webhook.verified = False webhook.put() return self.redirect('/account')
def post(self): self._require_registration() self._require_request_user_is_bundle_user() current_user_account_id = self.user_bundle.account.key.id() if not current_user_account_id: return self.redirect('/') client_id = self.request.get('client_id') if not client_id: return self.redirect('/') webhook = MobileClient.get_by_id(int(client_id), parent=ndb.Key(Account, current_user_account_id)) if not webhook or webhook.client_type != ClientType.WEBHOOK or current_user_account_id != webhook.user_id: return self.redirect('/') from helpers.tbans_helper import TBANSHelper response = TBANSHelper.verify_webhook(webhook.messaging_id, webhook.secret) webhook.verification_code = response.verification_key webhook.verified = False webhook.put() return self.redirect('/account')