def check_access(cls, request): if request.GET.get('data'): data = Sign().unsign(request.GET.get('data'), SMS_AGE * 2) if data.get('ip') == get_ip(request): user_agent = md5(request.META['HTTP_USER_AGENT']) if data.get('user_agent') == user_agent: return True
def send_link(cls, request, user): data = { 'ip': get_ip(request), 'user_agent': md5(request.META.get('HTTP_USER_AGENT')), } link = 'http://%s%s?data=%s' % ( Site.objects.get_current(), reverse('auth_login'), Sign().sign(data) ) send_mail( [user.email], _('Link for unlock access'), link )