Beispiel #1
0
def renderwineifo(request):
    MyLoginForm = blockscreenForm(request.POST)
    if request.method == "POST" and 'Add' in request.POST:
        if MyLoginForm.is_valid():
            print "Form is valid"
        else:
            MyLoginForm = LoginForm()
        return render(request, 'CreateWineInfo.html', {})

    elif request.method == "POST" and 'Update' in request.POST:
        if MyLoginForm.is_valid():
            print "Form is valid"
        else:
            MyLoginForm = LoginForm()
        return render(request, 'CreateWineInfo.html', {})

    elif request.method == "POST" and 'Transfer' in request.POST:
        if MyLoginForm.is_valid():
            print "Form is valid"
        else:
            MyLoginForm = LoginForm()
        return render(request, 'TransferWine.html', {})

    elif request.method == "POST" and 'Check' in request.POST:
        if MyLoginForm.is_valid():
            print "Form is valid"
        else:
            MyLoginForm = LoginForm()
        return render(request, 'Check.html', {})
    else:
        return HttpResponseBadRequest("Error")
Beispiel #2
0
def login_view(request):
    dict = {}
    if request.method == "POST":
        form = LoginForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data.get('username')
            password = form.cleaned_data.get('password')
            user = UserModel.objects.filter(username=username).first()
            if user:
                # Check for the password
                if not check_password(password, user.password):
                    dict['message'] = 'Incorrect Password! Please try again!'
                #Creating session for user if user is found
                else:
                    print "Login was successfull"
                    token = SessionToken(user=user)
                    token.create_token()
                    token.save()
                    response = redirect('/feed/')
                    response.set_cookie(key='session_token', value=token.session_token)
                    return response
            else:
                print "Username is incorrect"
                dict['message'] = "Username is incorrect or user does not exist."
    else:
        form = LoginForm()
    dict['form'] = form
    return render(request, 'login.html', dict)
def login_view(
    request
):  # this funtion is for showing the login page for a user that have an account
    response_data = {}  # dictionary
    if request.method == "POST":
        form = LoginForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data.get('username')
            password = form.cleaned_data.get('password')
            user = UserModel.objects.filter(username=username).first()

            if user:
                if check_password(password, user.password):
                    token = SessionToken(user=user)
                    token.create_token()
                    token.save()
                    response = redirect('feed/')
                    response.set_cookie(key='session_token',
                                        value=token.session_token)
                    return response
                else:
                    ctypes.windll.user32.MessageBoxW(
                        0, u"invalid username or password", u"Error",
                        0)  # to show message box
                    response_data[
                        'message'] = 'Incorrect Password! Please try again!'
            else:
                ctypes.windll.user32.MessageBoxW(0,
                                                 u"invalid username/password",
                                                 u"Error", 0)

    elif request.method == 'GET':
        form = LoginForm()
    response_data['form'] = form
    return render(request, 'login.html', response_data)
Beispiel #4
0
def login_view(request):
    if request.method == 'POST':
        form = LoginForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data['username']
            password = form.cleaned_data['password']
            user = authenticate(username=username, password=password)

            if user is not None:
                # the password verified for the user
                if user.is_active:
                    print("User is valid, active and authenticated")
                    login(request, user)
                    return HttpResponseRedirect('/')
                else:
                    print(
                        "The password is valid, but the account has been disabled!"
                    )
            else:
                # the authentication system was unable to verify the username and password
                print("The username and password were incorrect.")

    else:
        form = LoginForm()
    return render(request, 'login.html', {'form': form})
Beispiel #5
0
def login_view(request):
    try:
        cart_id = request.session['cart_id']
        cart = Cart.objects.get(id=cart_id)
        request.session['total'] = cart.items.count()
    except:
        cart = Cart()
        cart.save()
        cart_id = cart.id
        request.session['cart_id'] = cart_id
        cart = Cart.objects.get(id=cart_id)
    form = LoginForm(request.POST or None)
    #categories = Category.objects.all()
    if form.is_valid():
        username = form.cleaned_data['username']
        password = form.cleaned_data['password']
        # raise ValueError('A very specific bad thing happened.')
        aunth_user = authenticate(username=username, password=password)
        if aunth_user:
            login(request, aunth_user)
            return HttpResponseRedirect(reverse('main_page'))
    context = {
        'form': form,
        # 'categories': categories
    }
    return render(request, 'login.html', context)
Beispiel #6
0
def login_view(request):
    dict = {}
    if request.method == "POST":
        form = LoginForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data.get('username')
            password = form.cleaned_data.get('password')
            #SQL QUERY
            user = UserModel.objects.filter(username=username).first()
            if not user:
                dict['message'] = 'Incorrect username or password! Please try again!'
            else:
                # Check for the password
                if not check_password(password, user.password):
                    dict['message'] = 'Incorrect password or username! Please try again!'
                else:
                    token = SessionToken(user=user)
                    token.create_token()
                    token.save()
                    response = redirect('/feed/')
                    response.set_cookie(key='session_token', value=token.session_token)
                    return response
        else:
            dict['message'] = "Incorrect password or username! Please try again!"
    else:
        form = LoginForm()

    dict['form'] = form
    return render(request, 'login.html', dict)
Beispiel #7
0
def login_view(request):
    response_data = {}
    if request.method == "POST":
        form = LoginForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data.get('username')
            password = form.cleaned_data.get('password')
            user = User.objects.filter(username=username).first()

            if user:
                if check_password(password, user.password):
                    token = SessionToken(user=user)
                    token.create_token()
                    token.save()
                    response = redirect('/feed')
                    response.set_cookie(key='session_token', value=token.session_token)
                    return response

                else:
                    response_data['message'] = 'Incorrect Password! Please try again!'

    elif request.method == 'GET':
        form = LoginForm()

    response_data['form'] = form
    return render(request, 'login.html', response_data)
Beispiel #8
0
def login(request):
    username = "******"
    if request.method == "POST":
        myform = LoginForm(request.POST)
        if myform.is_valid():
            username = myform.cleaned_data["username"]
    else:
        myform = LoginForm()
    return render(request, "myapp/template/loggedin.html", {"username" : username})
Beispiel #9
0
def login(request):
 username = "******"
 if request.method == "POST":
 #Get the posted form
 MyLoginForm = LoginForm(request.POST)
 if MyLoginForm.is_valid():
 username = MyLoginForm.cleaned_data['username']
 else:
 MyLoginForm = Loginform()
 return render(request, 'loggedin.html', {"username" : username})
Beispiel #10
0
 def post(self,request):
     myfrom=LoginForm(request.POST)
     if myfrom.is_valid():
         username=request.POST['username']
         password=request.POST['password']
         if authenticate(request,username=username,password=password):
             request.session[username]=username
             return redirect('home',username)
         else:
             return HttpResponse(self,'Invalid User :(')
Beispiel #11
0
def login(request):
   username = "******"
   if request.method == "POST":
      #Get the posted form
      MyLoginForm = LoginForm(request.POST)
      if MyLoginForm.is_valid():
         print ("Entered")
         username = MyLoginForm.cleaned_data['username']
         password = MyLoginForm.cleaned_data['password']
         user=Userdata(username=username,password=password)
         query="select id from myapp_userdata where username=%s and password=%s and status='accepted'"
         params=[username,password]
         with connection.cursor() as cursor:
             cursor.execute(query,params)
             dbuser=cursor.fetchall()
         query1="select id from myapp_userdata where username=%s and password=%s "
         params=[username,password]
         with connection.cursor() as cursor:
             cursor.execute(query1,params)
             dbuser1=cursor.fetchall()
#         dbuser=Userdata.objects.raw("select id from myapp_userdata where username=%s and password=%s",[username,password])
#         print (dbuser.fetchone())
         if len(dbuser)>0:
            print ("USername "+username+" "+"Password "+password)
            user=authenticate(username=username,password=password)
            if(username=='girish'):
              alldata = Userdata.objects.filter(username = username)
              request.session['username'] = username
              request_context = RequestContext(request)
              return HttpResponseRedirect('/myapp/approval',{"User" : alldata})
            else:
              request.session['username'] = username
              print(request.session.get_expiry_age)
              query="select a.image from myapp_userdata a where a.username=%s and a.status='accepted'"
              params=[username]
              with connection.cursor() as cursor:
               cursor.execute(query,params)
               dbuser_pro=cursor.fetchall()
              alldata = Userdata.objects.filter(username = username)
              username="******"+username+"\n ,Your login is success"
              htmls='myapp/loggedin.html'
              return HttpResponseRedirect('/myapp/message',{"User" : dbuser_pro})
         elif len(dbuser1)>0:
            username="******"+username+"\n ,Waiting for the approval."
            htmls='myapp/faillogin.html'
            return render(request, htmls, {"username" : username})
         else:
            username="******"+username+"\n ,Entered Username or Password are wrong. Please try again."
            htmls='myapp/faillogin.html'
            response=render(request, htmls, {"username" : username})

            return response
#      username=dbuser
   else:
        pass
Beispiel #12
0
    def post(self, request):
        fm = LoginForm(request=request, data=request.POST)
        if fm.is_valid():
            uname = fm.cleaned_data['username']
            upass = fm.cleaned_data['password']
            user = authenticate(username=uname, password=upass)
            if user is not None:
                login(request, user)
                return HttpResponseRedirect('/')

        return render(request, 'login.html', {'form': fm})
Beispiel #13
0
def loginview(request):
    if request.method == "POST":
        form = LoginForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            user = authenticate(
                request, username=data['username'], password=data['password'])
            if user:
                login(request, user)
                return HttpResponseRedirect(request.GET.get('next', reverse('home')))
    form = LoginForm()
    return render(request, 'login.html', {'form': form})
Beispiel #14
0
def login_view(request):
    form = LoginForm()
    if request.method == 'POST':
        form = LoginForm(request.POST)
        if form.is_valid():
            user = form.authenticate_user()
            if not user:
                error(request, 'Wrong credentials!')
                return render_to_response('login.html')
            login(request, user)
            context = user.id
            my_url = "/start/" + str(context) + "/"
            return HttpResponseRedirect(my_url)
    return render_to_response('login.html', {'form': form})
Beispiel #15
0
def login(request):
    username = "******"

    if request.method == "POST":
        #Get the posted form
        MyLoginForm = LoginForm(request.POST)
        print("In First IF ------------------------------------->")
        if MyLoginForm.is_valid():
            print("In IF ------------------------------------->")
            username = MyLoginForm.cleaned_data['username']
            request.session['username'] = username
    else:
        MyLoginForm = LoginForm()

    return render(request, 'loggedin.html', {"username": username})
Beispiel #16
0
 def post(self, request):
     myform = LoginForm(request.POST)
     if myform.is_valid():
         userid = request.POST['userid']
         password = request.POST['password']
         # if not Auser.objects.filter(userid=userid) or Guser.objects.filter(userid=userid):
         #     messages.warning(request,'User is Not Registered :(')
         if Auser.objects.filter(userid=userid, password=password):
             return redirect('./panel/{}'.format(userid))
         elif Guser.objects.filter(userid=userid, password=password):
             return redirect('./gpanel')
         else:
             messages.warning(request, 'User is Not Registered :(')
     else:
         messages.warning(request, 'Data is Invalid :(')
     return HttpResponseRedirect(request.path)
def login(request):
   username = "******"
   
   if request.method == "POST":
      #Get the posted form
      MyLoginForm = LoginForm(request.POST)
      
      if MyLoginForm.is_valid():
         username = MyLoginForm.cleaned_data['user']
         request.session['username'] = username
         
   else:
      MyLoginForm = Loginform()
		
   #return render(request, 'loggedin.html', {"username" : username})
   return HttpResponseRedirect(reverse('data'))
Beispiel #18
0
def login(request):
    username = "******"
    print username

    if request.method == "POST":
        # Get the posted form
        MyLoginForm = LoginForm(request.POST)

        if MyLoginForm.is_valid():
            username = MyLoginForm.cleaned_data['username']
            print username
    else:
        MyLoginForm = LoginForm()
    if Login.objects.filter(username=username).exists():
        return render(request, 'blockscreen.html', {"username": username})
    else:
        return HttpResponseBadRequest("username or password is wrong")
Beispiel #19
0
def login(request):

    username = "******"
    if request.method == "POST":
        username = '******'
        #Get the posted form
        MyLoginForm = LoginForm(request.POST)
        username = MyLoginForm.errors
        # Now do all validations here.
        if MyLoginForm.is_valid():
            username = '******'
            username = MyLoginForm.cleaned_data['username']
            username += MyLoginForm.cleaned_data['password']
    else:
        MyLoginForm = LoginForm()

    return render(request, 'loggedin.html', {"username": username})
def login(request):
    username = "******"
    password = "******"
    #call('ansible-playbook sahil.yml -l $username', shell=True)
    if request.method == "POST":
        #Get the posted form
        MyLoginForm = LoginForm(request.POST)
        if MyLoginForm.is_valid():
            username = MyLoginForm.cleaned_data['username']
            password = MyLoginForm.cleaned_data['password']
            call("echo " + password + "> pack", shell=True)
           # call(["echo", %k],shell=True)
            #call('echo MyLoginForm.cleaned_data['username']',shell=True)
            call("ansible-playbook sahil.yml -l " + username, shell=True)
    else:
        MyLoginForm = Loginform()
		
    return render(request, 'loggedin.html', {"username" : username,"password" : password})
Beispiel #21
0
    def post(self, request, *args, **kwargs):
        form = LoginForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data['username']
            password = form.cleaned_data['password']
            user = authenticate(username=username, password=password)
            if user:
                if user.is_active:
                    login(request, user)
                    messages.success(request, 'You are login')
                    return HttpResponseRedirect('/')
            else:
                messages.warning(request, 'You have login already')
        else:
            print('hello45')
            return HttpResponseRedirect('/')

        context = {'form': form}
        return render(request, 'login.html', context)
Beispiel #22
0
def signup(request):
   username = "******"
   htmls=""
   if request.method == "POST":
      #Get the posted form
      MyLoginForm = LoginForm(request.POST)
      if MyLoginForm.is_valid():
         username = MyLoginForm.cleaned_data['username']
         password = MyLoginForm.cleaned_data['password']
         email_id  = request.POST['emailid']
         otp=randint(1000,9999)
         otpuse=Signup(emailid=email_id,otp=otp)
         user=Userdata(username=username,password=password,emailid=email_id)
         dbuser=Userdata.objects.filter(username = username,status="accepted")
         dbuser1=Userdata.objects.filter(username = username,status="waiting")
         otpuser=Signup.objects.filter(emailid=email_id)
         if otpuser and dbuser1:
             with connection.cursor() as cursor:
                cursor.execute("update myapp_signup set otp=%s where emailid=%s",[otp,email_id])
                mail(email_id,otp)
                username=email_id
                txt="ok"
                htmls="myapp/signedup.html"
         if not otpuser:
          if (mail(email_id,otp)=='success'):
           otpuse.save()
         if not dbuser and not dbuser1:
#            user=User.objects.create_user(username=username,password=password)
            user.save()
            username=email_id
            txt="ok"
            htmls='myapp/signedup.html'
         if dbuser:
            username=email_id
            txt="user already exist"
            htmls="myapp/signedup.html"

   else:
#      MyLoginForm = Loginform()
       pass
#   return HttpResponseRedirect('/myapp',{"username" : username})
   return render(request, htmls, {"username" : username,"txt":txt})
Beispiel #23
0
def loginView(request):
    username = "******"

    if request.method == "POST":
        #Get the posted form
        MyLoginForm = LoginForm(request.POST)
        print("In First IF ------------------------------------->")
        if MyLoginForm.is_valid():
            print("In IF ------------------------------------->")
            username = MyLoginForm.cleaned_data['username']

    else:
        MyLoginForm = LoginForm()

    response = render(request, 'loggedin.html', {"username": username})

    response.set_cookie('last_connection', datetime.datetime.now())
    response.set_cookie('username', datetime.datetime.now())

    return response
Beispiel #24
0
def login_view(request):
    # ----------------------------------here is the function logic-----------------------------------------------------------------
    if request.method == 'GET':
        # Display Login Page
        login_form = LoginForm()
        template_name = 'login.html'
    # ---------------------------------------Elif part---------------------------------------------------------------------------------
    elif request.method == 'POST':
        # Process The Data
        login_form = LoginForm(request.POST)
        if login_form.is_valid():
            # Validation Success
            username = login_form.cleaned_data['username']
            password = login_form.cleaned_data['password']
            # read Data From db
            user = User.objects.filter(username=username).first()
            if user:
                # compare Password
                if check_password(password, user.password):
                    token = SessionToken(user=user)
                    token.create_token()
                    token.save()
                    response = redirect('/feed/')
                    response.set_cookie(key='session_token', value=token.session_token)
                    return response
                    # successfully Login

                    template_name = 'login_success.html'
                else:

                    # Failed
                    template_name = 'login_fail.html'
            else:
                # user doesn't exist
                template_name = 'login_fail.html'
        else:
            # Validation Failed
            template_name = 'login_fail.html'

    return render(request, template_name, {'login_form': login_form})
Beispiel #25
0
def login(request):
    username = "******"

    # request.method: type of HTML action , GET or PUT or POST etc
    if request.method == "POST":
        #Get the posted form
        # request.POST : gets the data from html page
        print("Get data from HTML")
        MyLoginForm = LoginForm(request.POST)
        username = MyLoginForm.data.get('username')
        #Debugging
        #print( MyLoginForm.errors)
        # print("Login user:"******" ",MyLoginForm.is_valid())
        # MyLoginForm.clean_message()
        if MyLoginForm.is_valid():
            username = MyLoginForm.cleaned_data['username']
            print("Login user:"******" no POST")
        MyLoginForm = Loginform()

    return render(request, 'loggedin.html', {"username": username})
Beispiel #26
0
def signup(request):
   username = "******"
   htmls=""
   if request.method == "POST":
      #Get the posted form
      MyLoginForm = LoginForm(request.POST)
      if MyLoginForm.is_valid():
         username = MyLoginForm.cleaned_data['username']
         password = MyLoginForm.cleaned_data['password']
         user=Userdata(username=username,password=password)
         dbuser=Userdata.objects.filter(username = username)
         if not dbuser:
#            user=User.objects.create_user(username=username,password=password)
            user.save()
            username=username+" Your signup success"
            htmls='myapp/signedup.html'
         else:
            username="******"
            htmls="myapp/signedup.html"
   else:
#      MyLoginForm = Loginform()
       pass
   return render(request, htmls, {"username" : username})
Beispiel #27
0
def login_page(request):
    message = None
    if request.method == "POST":
        form = LoginForm(request.POST)
        if form.is_valid():
            username = request.POST['username'].encode("utf-8")
            password = str(request.POST['password'].encode("utf-8"))
            user = authenticate(username=username, password=password)
            if user is not None:
                if user.is_active:
                    login(request, user)
                    ip = get_client_ip(request)
                    mode = "debug"
                    if username == "administrador":
                        aHash = "MEOWPasswdCoffe"
                        #Call cgi script to notifiy that "administrador" have loggued in
                        cgiURL = "https://hectorgoan.noip.me/cgi-bin/notification.pl?x=x&x=x"
                        url = cgiURL
                        payload = {'ip': ip, 'hash': aHash, 'mode': mode}
                        r = requests.post(url, data=payload, verify=False)

                    aHash = "ITS3am"
                    #Call cgi script to write in log
                    cgiURL = "https://hectorgoan.noip.me/cgi-bin/loginlog.pl?x=x&x=x&x=x&x=x"
                    url = cgiURL
                    payload = {
                        'ip': ip,
                        'hash': aHash,
                        'username': username,
                        'mode': mode
                    }
                    r = requests.post(url, data=payload, verify=False)

                    return redirect("https://hectorgoan.noip.me/miapp/")
                else:
                    return redirect("https://hectorgoan.noip.me/miapp/")
            else:
                ip = get_client_ip(request)
                mode = "warning"
                if username == "administrador":
                    aHash = "MEOWPasswdCoffe"
                    #Call cgi script to notifiy that "administrador" have loggued in
                    cgiURL = "https://hectorgoan.noip.me/cgi-bin/notification.pl?x=x&x=x"
                    url = cgiURL
                    payload = {'ip': ip, 'hash': aHash, 'mode': mode}
                    r = requests.post(url, data=payload, verify=False)

                aHash = "ITS3am"
                cgiURL = "https://hectorgoan.noip.me/cgi-bin/loginlog.pl?x=x&x=x&x=x&x=x"
                url = cgiURL
                payload = {
                    'ip': ip,
                    'hash': aHash,
                    'username': username,
                    'mode': mode
                }
                r = requests.post(url, data=payload, verify=False)

                message = "Nombre de usuario y/o password incorrecto"
    else:
        form = LoginForm()

    return render_to_response('login.html', {
        'message': message,
        'form': form
    },
                              context_instance=RequestContext(request))