Ejemplo n.º 1
0
def regster(request):
    if request.method == 'GET':

        data = {
            'title': "注册",
        }

        return render(request, 'user/register.html', context=data)
    elif request.method == "POST":
        username = request.POST.get("username")
        email = request.POST.get("email")
        password = request.POST.get("password")
        icon = request.FILES.get("icon")

        # password = hash_str(password)
        password = make_password(password)

        user = AXFUser()
        user.u_username = username
        user.u_password = password
        user.u_email = email
        user.u_icon = icon

        user.save()

        u_token = uuid.uuid4().hex
        cache.set(u_token, user.id, timeout=60 * 60 * 24)

        send_email_activate(username, email, u_token)

        return redirect(reverse("axf:login"))
Ejemplo n.º 2
0
def register(request):
    if request.method == 'GET':
        data = {
            'title': '注册',
        }

        return render(request, 'user/register.html', context=data)
    elif request.method == "POST":
        username = request.POST.get('username')
        email = request.POST.get('email')
        password = request.POST.get('password')
        icon = request.FILES.get('icon')

        password = hash_str(password)

        user = AXFUser()
        user.u_username = username
        user.u_password = password
        user.u_email = email
        user.u_icon = icon

        user.save()

        u_token = uuid.uuid4().hex

        cache.set(u_token, user.id, timeout=68 * 60 * 24)

        send_email_activate(username, email, u_token)

        return redirect(reverse('axf:login'))
Ejemplo n.º 3
0
def register(request):
    if request.method == 'GET':
        data = {
            'title': '注册',
        }
        return render(request, 'user/register.html', context=data)
    elif request.method == "POST":
        name = request.POST.get("name")
        email = request.POST.get("email")
        password = request.POST.get("password")
        icon = request.FILES.get("icon")

        user = AXFUser()
        user.u_username = name
        user.u_email = email
        user.u_password = make_password(password)
        user.u_icon = icon
        user.save()

        # 发送激活邮件
        u_token = uuid.uuid4().hex

        cache.set(u_token, user.id, timeout=60 * 60 * 24)

        send_email_activate(name, email, u_token)

        return render(request, 'user/login.html')
Ejemplo n.º 4
0
def register(request):
    if request.method=='GET':
        data={
            'title':'注册'
        }
        return render(request,'user/register.html',context=data)
    if request.method=='POST':
        username=request.POST.get('username')
        email=request.POST.get('email')
        password=request.POST.get('password')
        icon=request.FILES.get('icon')

        # password=has_str(password)
        password=make_password(password)

        user=AXFUser()
        user.u_username=username
        user.u_email=email
        user.u_password=password
        user.u_icon=icon
        user.save()
        u_token=uuid.uuid4().hex
        cache=caches['redis_backend']
        cache.set(u_token,user.id,timeout=60*60*24)
        receive_email=email
        send_email_activate(username,receive_email,u_token)
        return HttpResponse('注册成功,请前往邮箱进行激活')
Ejemplo n.º 5
0
def register(request):
    if request.method == "GET":
        data = {
            "title": "User Registration",
        }
        return render(request, 'user/user_register.html', context=data)
    elif request.method == "POST":
        username = request.POST.get(
            "username")  # name attribute in user_register.html
        email = request.POST.get("email")
        password = request.POST.get("password")
        icon = request.FILES.get("icon")

        #password = hash_str(password)
        password = make_password(password)  #add time point
        #check_password('user input', 'encoded') return true false as comparison result

        user = AXFUser()
        user.u_username = username
        user.u_email = email
        user.u_password = password
        user.u_icon = icon

        user.save()

        u_token = uuid.uuid4().hex

        cache.set(u_token, user.id, timeout=60 * 60 * 24)

        send_email_activate(username, email, u_token)

        return redirect(reverse('axf:login'))
Ejemplo n.º 6
0
def register(request):
    if request.method == 'GET':

        data = {'title': '注册'}
        return render(request, 'user/register.html', context=data)
    elif request.method == 'POST':
        username = request.POST.get('username')
        email = request.POST.get('email')
        password = request.POST.get('password')
        icon = request.POST.get('icon')

        user = AXFUser()
        user.u_username = username
        user.u_email = email
        user.u_password = password
        user.u_icon = icon

        user.save()

        return redirect(reverse('axf:login'))
Ejemplo n.º 7
0
def register(request):
    if request.method == 'GET':

        data = {
            'title': "注册",
        }

        return render(request, 'user/register.html', context=data)

    elif request.method == 'POST':
        # pdb.set_trace()
        username = request.POST.get("username")
        password = request.POST.get("password")
        email = request.POST.get("email")
        icon = request.FILES.get("icon")

        # 自己写的密码加密
        # password = hash_str(password)

        # django自带的加密密码
        password = make_password(password)

        user = AXFUser()
        user.u_username = username
        user.u_password = password
        user.u_email = email
        user.u_icon = icon

        user.save()

        # .hex将uuid的格式变成字符串
        u_token = uuid.uuid4().hex

        # 将用户的id做为缓存的值 在激活的时候用id去看是哪个用户 然后并激活
        cache.set(u_token, user.id, timeout=60 * 60 * 24)

        send_email_activate_celery.delay(username=username,
                                         receive=email,
                                         u_token=u_token)

        return redirect(reverse('axf:login'))
Ejemplo n.º 8
0
def register(request):
    if request.method == "GET":
        data = {
            "title": "注册",
        }
        return render(request, 'user/register.html', context=data)
    elif request.method == "POST":
        username = request.POST.get("username")
        email = request.POST.get("email")
        password = request.POST.get("password")
        icon = request.FILES.get("icon")

        password = make_password(password)
        user = AXFUser()
        user.u_username = username
        user.u_email = email
        user.u_password = password
        user.u_icon = icon
        user.save()

        return redirect(reverse("axf:login"))
Ejemplo n.º 9
0
def register(request):
    if request.method == 'GET':
        data = {
            'data': '注册',
        }
        return render(request, 'user/register.html', context=data)
    elif request.method == 'POST':
        username = request.POST.get('username')
        email = request.POST.get('email')
        password = request.POST.get('password')
        icon = request.POST.get('icon')

        # password = hash_str(password)
        # password = make_password(password)
        user = AXFUser()
        user.u_uname = username
        user.u_email = email
        user.u_password = password
        user.u_icon = icon
        user.save()
        return redirect(reverse('login'))  #这里只要注册成功就直接返回重定向到登录页面
Ejemplo n.º 10
0
def register(request):
    if request.method == 'GET':
        data = {'title': '注册'}
        return render(request, 'user/register.html', context=data)
    elif request.method == 'POST':

        username = request.POST.get('username')
        password = request.POST.get('password')
        password = make_password(password)
        email = request.POST.get('email')
        icon = request.FILES.get('icon')

        user = AXFUser()
        user.u_username = username
        user.u_password = password
        user.u_email = email
        user.u_icon = icon

        user.save()
        u_token = uuid.uuid4().hex
        print(u_token)
        cache.set(u_token, user.id, timeout=60 * 60 * 24)
        send_email_activate.delay(username, email, u_token)
        return render(request, 'user/login.html')
Ejemplo n.º 11
0
Archivo: views.py Proyecto: lu-my/demos
def register():
    if request.method == "GET":
        return render_template('user/register.html')
    elif request.method == "POST":

        name = request.form.get("name")
        email = request.form.get("email")
        password = request.form.get("password")
        filename = photos.save(request.files['icon'])

        print(password)
        user = AXFUser()
        user.u_username = name
        user.u_email = email
        user.u_password = generate_password_hash(password)
        user.u_icon = filename

        db.session.add(user)
        db.session.commit()

        return 'register success'