Exemplo n.º 1
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=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())
Exemplo n.º 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())
Exemplo n.º 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())
Exemplo n.º 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())