def dehydrate(self, bundle): u = bundle.request.user key = get_user_encryption_key(u.username) try: bundle.data['password'] = decrypt(bundle.data['password'], key) except: bundle.data['password'] = None return bundle
def check_session(request): key = get_user_encryption_key(request.user.username) if key: key = True else: key = False data = {"status": key} return HttpResponse(json.dumps(data), content_type="application/json")
def dehydrate(self, bundle): u = bundle.request.user key = get_user_encryption_key(u.username) try: bundle.data["password"] = decrypt(bundle.data["password"], key) except: bundle.data["password"] = None return bundle
def save(self, *args, **kwargs): user = threadlocal.get_current_user() key = get_user_encryption_key(user.username) or kwargs.get('key') # if no key throw error if not key: raise StandardError("If calling save from outside of a request, " \ "you must specify 'key' as a kwarg") self.password = encrypt(self.password, key) super(Credential, self).save(*args, **kwargs)
def check_session(request): key = get_user_encryption_key(request.user.username) if key: key = True else: key = False data = { 'status': key, } return HttpResponse(json.dumps(data), content_type='application/json')
def encryption_key(request): u = request.user key = get_user_encryption_key(u.username) return { 'ENCRYPTION_KEY': key }
def encryption_key(request): u = request.user key = get_user_encryption_key(u.username) return {'ENCRYPTION_KEY': key}