|  | from django.core.cache import cache
 | 
						
						
						
							|  | from rest_framework.exceptions import ParseError
 | 
						
						
						
							|  | 
 | 
						
						
						
							|  | 
 | 
						
						
						
							|  | def check_phone_code(phone, code, raise_exception=True):
 | 
						
						
						
							|  |     code_exist = cache.get(phone, None)
 | 
						
						
						
							|  |     if code_exist == code:
 | 
						
						
						
							|  |         return True
 | 
						
						
						
							|  |     if raise_exception:
 | 
						
						
						
							|  |         raise ParseError('验证码错误')
 | 
						
						
						
							|  |     return False
 |