示例#1
0
 def dehydrate(self, bundle):
     password = crypto.parse_password(bundle.obj.password)
     bundle.data['salt'] = crypto.to_string(password['salt'])
     try:
         bundle.data['one_time_salt'] = bundle.request.session['one_time_salt']
     except KeyError:
         bundle.data['one_time_salt'] = crypto.to_string(self.rotate_one_time_salt(bundle.request))
     if bundle.request.user == bundle.obj and bundle.request.user.is_authenticated():
         bundle.data['data'] = bundle.obj.profile.data
     return bundle
示例#2
0
 def rotate_one_time_salt(self, request):
     one_time_salt = crypto.get_salt()
     request.session['one_time_salt'] = crypto.to_string(one_time_salt)
     return one_time_salt