Esempio n. 1
0
def register(request):
    if request.method == "POST":
        if User.objects.filter(email=request.POST['email']).count() == 0:
            if prereg.objects.filter(mail=request.POST['email']).count() == 0:
                prereg(mail=request.POST['email'], smash=makeHash('md5', request.POST['email'])).save()
                print "/doreg/?id=" + makeHash('md5', request.POST['email']) + "&mail=" + request.POST['email']
                return render(request, 'index.html', {'panel': 2, 'success': True, 'message': 'دوست عزیز برو میلتو چک کن'})
            return render(request, 'index.html', {'panel': 2, 'success': False, 'message': 'دوست عزیز برو میلتو چک کن'})
        return render(request, 'index.html', {'panel': 2, 'success': False, 'message': 'این ایمیل وجود داره انقد نزن'})
    return render(request, 'index.html', {'panel': 2, 'success': False, 'message': 'ثبت نام با شکست مواجه شد'})
Esempio n. 2
0
def password_change(request):
    if request.method == 'POST':
        if request.POST.get('password'):
            a = User.objects.filter(email=request.session['email'])
            if len(a) > 0:
                a = a[0]
                a.password = makeHash('md5', request.POST.get('password').encode('utf-8'), request.session['email'].encode('utf-8'))
                a.save()
                return HttpResponseRedirect('/profile?mes=1')
    return HttpResponseRedirect('/profile?mes=0')
Esempio n. 3
0
def do_reg(request):
    if request.method == 'GET' and request.GET.get('id') and request.GET.get('mail'):
        a = prereg.objects.filter(mail=request.GET['mail'], smash=request.GET['id'])
        if a.count():
            a[0].delete()
            return render(request, 'register.html', {'mail': request.GET['mail']})
    elif request.method == 'POST':
        if request.POST.get('firstname') and request.POST.get('lastname') and \
            request.POST.get('password') and request.POST.get('email'):
            User(first_name=request.POST['firstname'], last_name=request.POST['lastname'], email=request.POST['email'],
                 password=makeHash('md5', request.POST['password'].encode('utf-8'), request.POST['email'].encode('utf-8')),
                 date_create=datetime.now()).save()
            return render(request, 'index.html', {"mes": 'خوب به سلامتی ثبت نام شدی'})
    return render(request, 'index.html', {'mes': "ههههه ههههه ههههه"})
Esempio n. 4
0
def password_reset_done(request):
    if request.POST.has_key('password') and request.POST.has_key('password2') and request.POST.has_key('token') and request.POST.has_key('user_id'):
        try:
            user_obj = User.objects.get(id=request.POST['user_id'])
        except User.DoesNotExist:
            return render(request, 'password_reset_done.html', {'success': False})
        else:
            if is_valid_token(request.POST['token'], user_obj) and request.POST['password'] == request.POST['password2']:
                #user_obj.password = request.POST['password']
                user_obj.password = makeHash('md5', request.POST['password'].encode("utf8"), user_obj.email.encode("utf8"))
                user_obj.save()

                return render(request, 'password_reset_done.html', {'success': True})
            else:
                return render(request, 'password_reset_done.html', {'success': False})

    else:
        return render(request, 'password_reset_done.html', {'success': False})
Esempio n. 5
0
 def key(self):
     return makeHash("md5", self.password.encode("utf-8"), self.email.encode("utf-8"))
Esempio n. 6
0
 def is_valid_pass(self, pwd):
     return makeHash("md5", pwd.encode("utf-8"), self.email.encode("utf-8")) == self.password
Esempio n. 7
0
 def save_model(self, request, obj, form, change):
     if "password" in form.changed_data:
         obj.request = False
         obj.password = makeHash("md5", obj.password.encode("utf8"), obj.email.encode("utf8"))
     obj.save()