コード例 #1
0
ファイル: views.py プロジェクト: AaronWo/will-server
def login(request):
    email = request.POST['email']
    password = request.POST['passwd']
    try:
        user = User.objects.get(email = email)
        if not user.password == calc_md5(password):
            raise ValueError('password is incorrect')
    except:
        return HttpResponseBadRequest('login failed')
    response = redirect(reverse('wills:will_list', args=[user.id]))
    response.set_cookie('userid', user.id)
    return response
コード例 #2
0
ファイル: views.py プロジェクト: AaronWo/will-server
def regist(request):
    pwd = request.POST.get('passwd')
    if not len(pwd.strip()) >= 6 or not len(pwd.strip()) <= 12:
        return HttpResponseBadRequest('password illegal')
    pwd = calc_md5(pwd)
    (user, first_create) = regist_user_email(request.POST.get('email'), 
            pwd)
    logger.info(user, first_create)
    logger.info(first_create)
    if not first_create:
        return HttpResponseBadRequest('the email is being used')
    response = redirect(reverse('wills:will_list', args=[user.id]))
    response.set_cookie('userid', user.id)
    return response