mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	Move to a common random token generation function instead of several one-offs.
(imported from commit 3217de5384088deff68fbffc6bd481c045a76817)
This commit is contained in:
		@@ -1,8 +1,11 @@
 | 
			
		||||
# -*- coding: utf-8 -*-
 | 
			
		||||
from __future__ import absolute_import
 | 
			
		||||
 | 
			
		||||
import base64
 | 
			
		||||
import hashlib
 | 
			
		||||
import os
 | 
			
		||||
from time import sleep
 | 
			
		||||
 | 
			
		||||
from django.conf import settings
 | 
			
		||||
 | 
			
		||||
def statsd_key(val, clean_periods=False):
 | 
			
		||||
@@ -93,3 +96,6 @@ def log_statsd_event(name):
 | 
			
		||||
    """
 | 
			
		||||
    event_name = "events.%s" % (name,)
 | 
			
		||||
    statsd.incr(event_name)
 | 
			
		||||
 | 
			
		||||
def generate_random_token(length):
 | 
			
		||||
    return base64.b16encode(os.urandom(length / 2)).lower()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user