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())
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())
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())