예제 #1
0
파일: viewsuser.py 프로젝트: xf22001/myblog
def login(request):
    if utility.HasPostData(request, "ok"):
        username = utility.GetPostData(request, "username")
        password = utility.GetPostData(request, "password")

        user = auth.authenticate(username=username, password=password)
        if user is not None:
            try:
                # userProfile=user.get_profile()
                currentUserProfile = UserProfile.objects.get(user=user)
            except:
                common.createUserProfile(user)
            try:
                blog = Blog.objects.get(user_id=user.id)
            except:
                common.createBlog(user)

            if user.is_active:
                auth.login(request, user)
                return HttpResponseRedirect("/")
            else:
                return HttpResponseRedirect("")
        else:
            return HttpResponseRedirect("")
    else:
        return utility.my_render_to_response(request, "login.html", locals())
예제 #2
0
def login(request):
    if utility.HasPostData(request,"ok"):
        username=utility.GetPostData(request,"username")
        password=utility.GetPostData(request,"password")

        user=auth.authenticate(username=username,password=password)
        if user is not None:
            try:
                userProfile=UserProfile.objects.get(user_id=user.id)
            except:
                common.createUserProfile(user)
            try:
                blog=Blog.objects.get(user_id=user.id)
            except:
                common.createBlog(user)

            if user.is_active:
                auth.login(request,user)
                return HttpResponseRedirect('/')
            else:
                return HttpResponseRedirect('')
        else:
            return HttpResponseRedirect('')
    else:
        return utility.my_render_to_response(request,"login.html",locals())
예제 #3
0
def register(request):
    if utility.HasPostData(request,"ok"):
        username=utility.GetPostData(request,"username")
        password=utility.GetPostData(request,"password")
        email=utility.GetPostData(request,"email")

        user=User.objects.create_user(username,email,password)
        user.first_name=username
        user.save()

        common.createUserProfile(user)
        common.createBlog(user)

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request,"register.html",locals())
예제 #4
0
def register(request):
    if utility.HasPostData(request,"ok"):
        username=utility.GetPostData(request,"username")
        password=utility.GetPostData(request,"password")
        email=utility.GetPostData(request,"email")

        user=User.objects.create_user(username,email,password)
        user.first_name=username
        user.save()

        common.createUserProfile(user)
        common.createBlog(user)

        return HttpResponseRedirect('/')
    else:
        return utility.my_render_to_response(request,"register.html",locals())