Exemplo n.º 1
0
def myregister(request):
    if request.method == 'POST':

        name = request.POST.get('name')
        uname = request.POST.get('uname')
        email = request.POST.get('email')
        password = request.POST.get('password')
        password1 = request.POST.get('password1')

        if password != password1:
            msg = "Password is not matching"
            return render(request, 'front/message.html', {'msg': msg})

        if len(User.objects.filter(username=uname)) != 0 and len(
                User.objects.filter(email=email)) != 0:
            msg = "User already exists"
            return render(request, 'front/message.html', {'msg': msg})
        user = User.objects.create_user(username=uname,
                                        email=email,
                                        password=password)
        user.save()
        b = Manager(name=name, uname=uname, email=email)
        b.save()

        return redirect('mylogin')

    return render(request, 'front/login.html')
Exemplo n.º 2
0
def create_user(request):
    if request.method == 'POST':
        uform = UserForm(data=request.POST)
        pform = UserProfileForm(data=request.POST)

        if uform.is_valid() and pform.is_valid():
            new_user = User.objects.create_user(
                username=uform.cleaned_data['username'],
                email=uform.cleaned_data['email'],
                password=uform.cleaned_data['password1'],
                first_name=uform.cleaned_data['first_name'],
                last_name=uform.cleaned_data['last_name'])
            role = pform.cleaned_data['role']
            if role == 'M':
                manager = Manager(manager=new_user)
                manager.save()
            if role == 'W':
                waiter = Waiter(waiter=new_user)
                waiter.save()
            if role == 'B':
                bartender = Bartender(bartender=new_user)
                bartender.save()
            return HttpResponseRedirect('/manager/')

    else:
        uform = UserForm(data=request.POST)
        pform = UserForm(data=request.POST)
    variables = RequestContext(request, {
        'uform': uform,
        'pform': pform
    })

    return render_to_response('create_user.html',
                              variables)
Exemplo n.º 3
0
def post_register(request):

    if request.method == "POST":

        name = request.POST.get("name")
        username = request.POST.get("username")
        email = request.POST.get("email")
        password = request.POST.get("password")
        confirm_password = request.POST.get("confirm_password")

        # Custom Validation
        Error_dict = {}

        if name == "":
            Error_dict.update({'name': "Name field required"})

        if username == "":
            Error_dict.update({'username': "******"})

        if email == "":
            Error_dict.update({'email': "Email field required"})

        if password == "":
            Error_dict.update({'password': "******"})
        elif len(password) < 6:
            Error_dict.update({'password': "******"})

        if confirm_password == "":
            Error_dict.update(
                {'confirm_password': "******"})
        elif len(confirm_password) < 6:
            Error_dict.update(
                {'confirm_password': "******"})
        elif confirm_password != password:
            Error_dict.update(
                {'confirm_password': "******"})

        if len(Error_dict) != 0:
            return render(request, 'main/front/register.html',
                          {'error': Error_dict})

        if len(User.objects.filter(email=email)) == 0 and len(
                User.objects.filter(username=username)) == 0:

            password = make_password(password)

            user = User.objects.create(email=email,
                                       username=username,
                                       password=password)

            manager = Manager(name=name, email=email, user_text=username)
            manager.save()

            messages.success(request,
                             'Registered successfully, You can login Now!')
            return redirect(reverse('login'))

        else:
            messages.error(request, 'User Already Exists')
            return redirect(reverse('register.show'))
Exemplo n.º 4
0
def add(user, password):
    h = hashlib.md5()
    h.update(str(password).encode('utf-8'))
    password = h.hexdigest()
    now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    db = Manager(name=user, password=password, date=now, permission=1)
    # 更新数据
    db.save()
Exemplo n.º 5
0
def myregister(request):
    if request.method == 'POST':
        name = request.POST.get('name')
        uname = request.POST.get('uname')
        email = request.POST.get('email')
        password1 = request.POST.get('password1')
        password2 = request.POST.get('password2')
        if name == "":
            msg = "Please Input Your Name"
            return render(request, 'front/msgbox.html', {'msg': msg})
        if password1 != password2:
            msg = "Your Password Didn't Match"
            return render(request, 'front/msgbox.html', {'msg': msg})

        count1 = 0
        count2 = 0
        count3 = 0
        for i in password1:
            if "0" < i < "9":
                count1 = 1
            if "A" < i < "Z":
                count2 = 1
            if "a" < i < "z":
                count3 = 1

        if count1 == 0 or count2 == 0 or count3 == 0:
            msg = "Your Password Didn't Strong Enough"
            return render(request, 'front/msgbox.html', {'msg': msg})

        if len(password1) < 8:
            msg = "Your Password Must be Greater Than 8 Characters"
            return render(request, 'front/msgbox.html', {'msg': msg})

        if len(User.objects.filter(username=uname)) == 0 and len(
                User.objects.filter(email=email)) == 0:
            ip, is_routable = get_client_ip(request)
            if ip is None:
                ip = "0.0.0.0"

            try:
                response = DbIpCity.get(ip, api_key='free')
                country = response.country + " | " + response.city

            except:
                country = "Unknown"

            user = User.objects.create_user(username=uname,
                                            email=email,
                                            password=password1)
            b = Manager(name=name,
                        utxt=uname,
                        email=email,
                        ip=ip,
                        country=country)
            b.save()

    return render(request, 'front/login.html')
Exemplo n.º 6
0
def myregister(request):

    if request.method == 'POST':

        name = request.POST.get('name')
        uname = request.POST.get('uname')
        email = request.POST.get('email')
        password1 = request.POST.get('password1')
        password2 = request.POST.get('password2')

        if name == '':
            msg = "Input Your Name"
            return render(request, 'front/msgbox.html', {'msg': msg})

        if uname == "":
            msg = "Input Your Username"
            return render(request, 'front/msgbox.html', {'msg': msg})

        if password1 != password2:
            msg = "Your Passwords Don't Match"
            return render(request, 'front/msgbox.html', {'msg': msg})

        count1 = 0
        count2 = 0
        count3 = 0
        count4 = 0

        for i in password1:

            if i > "0" and i < "9":
                count1 = 1
            if i > "A" and i < "Z":
                count2 = 1
            if i > 'a' and i < 'z':
                count3 = 1
            if i > "!" and i < "(":
                count4 = 1

        if count1 == 0 or count2 == 0 or count3 == 0 or count4 == 0:
            msg = "Your Password Is Not Strong"
            return render(request, 'front/msgbox.html', {'msg': msg})

        if len(password1) < 8:
            msg = "Your Password Must Be 8 Characters"
            return render(request, 'front/msgbox.html', {'msg': msg})

        if len(User.objects.filter(username=uname)) == 0 and len(
                User.objects.filter(email=email)) == 0:

            user = User.objects.create_user(username=uname,
                                            email=email,
                                            password=password1)
            b = Manager(name=name, utxt=uname, email=email)
            b.save()

    return render(request, 'front/login.html')
Exemplo n.º 7
0
def my_register(request): 

    if request.method == 'POST':
        name = request.POST.get('name')
        uname = request.POST.get('uname')
        email = request.POST.get('email')
        password1 = request.POST.get('password1')
        password2 = request.POST.get('password2')

        if name == "" :
            msg = "Input Your Name"
            return render(request , 'front/msgbox.html' , {'msg' : msg})

            
        if password1 != password2 :
            msg = "Your Password Did not match"
            return render(request , 'front/msgbox.html', {'msg' : msg})

        #Check whether password is Strong enough
        #Start
        count1 = 0 
        count2 = 0 
        count3 = 0 
        count4 = 0 

        for i in password1:
            if i>"0" and i<"9" :
                count1 = 1 
            if i>"A" and i<"Z" :
                count2 = 1 
            if i>"a" and i<"z":
                count3 = 1
            if i>"!" and i<"" :
                count4 = 1 

        if count1 == 0 or count2 == 0 or count3 == 0 or count4 == 4 :
            msg = "Your Password is not Strong"
            return render(request , 'front/msgbox.html', {'msg' : msg})
        
        if len(password1) < 8 :
            msg = "Your Password must be 8 characters"
            return render(request , 'front/msgbox.html', {'msg' : msg})
        #END

        
        if len(User.objects.filter(username=uname)) == 0 and len(User.objects.filter(email=email)) == 0 :
            user = User.objects.create_user(username=uname , email = email , password = password1)
            b = Manager(name=name , utxt = uname , email=email)
            b.save()





    
    return render(request , 'front/login.html')    
Exemplo n.º 8
0
def myregister(request):

    if request.method == 'POST':

        name = request.POST.get('name')
        uname = request.POST.get('uname')
        email = request.POST.get('email')
        pass1 = request.POST.get('password1')
        pass2 = request.POST.get('password2')

        if name == "":
            msg = "Please Input your Name"
            return render(request, 'front/message.html', {'msg': msg})

        # Check if passwords match
        if pass1 != pass2:
            msg = "Your Passwords do not Match"
            return render(request, 'front/message.html', {'msg': msg})

        # Check strenth of new password
        count1 = 0
        count2 = 0
        count3 = 0
        count4 = 0

        for i in pass1:

            if i > "0" and i < "9":
                count1 = 1
            if i > "A" and i < "Z":
                count2 = 1
            if i > 'a' and i < 'z':
                count3 = 1
            if i > "!" and i < "@":
                count4 = 1

        if count1 == 0 or count2 == 0 or count3 == 0 or count4 == 0:
            msg = "Your Passwords is Not Strong Enough"
            return render(request, 'front/message.html', {'msg': msg})

        # Contains at least 8 chars
        if len(pass1) < 8:
            msg = "Your Passwords must be at Least 8 Characters"
            return render(request, 'front/message.html', {'msg': msg})

        # If user and email not in DB, then create user
        if len(User.objects.filter(username=uname)) == 0 and len(
                User.objects.filter(email=email)) == 0:
            user = User.objects.create_user(username=uname,
                                            email=email,
                                            password=pass1)
            b = Manager(name=name, utxt=uname, email=email)
            b.save()

    msg = "Thank you very much for signing up. The administrators of the website will view your profile and approve your admission shortly."
    return render(request, 'front/message.html', {'msg': msg})
Exemplo n.º 9
0
def my_register(request):

    if request.method == 'POST':

        name = request.POST.get('name')
        uname = request.POST.get('uname')
        email = request.POST.get('email')
        password1 = request.POST.get('password1')
        password2 = request.POST.get('password2')


        if password1 != password2:
            msg = "Your Password Did Not Match!"
            return render(request, 'front/msgbox.html', {'msg':msg})

        if len(password1) < 8:
                msg = "Your Password Must Have At Least 8 Characters"
                return render(request, 'front/msgbox.html', {'msg':msg})

        count1 = 0
        count2 = 0
        count3 = 0 
        count4 = 0

        for i in password1 :

            if i >= "0" and i <= "9" :
                count1 = 1
            if i >= "A" and i <= "Z" :
                count2 = 1
            if i >= 'a' and i <= 'z' :
                count3 = 1
            if i > "!" and i < "(" :
                count4 = 1

        if count1 == 0 or count2 == 0 or count3 == 0 or count4 == 0 :
            msg = "Your Pass Is Not Strong"
            return render(request, 'front/msgbox.html', {'msg':msg})

        if len(User.objects.filter(username=uname)) == 0 and len(User.objects.filter(email=email)) == 0:

            ip, is_routable = get_client_ip(request)

            if ip is None:
                ip = "0.0.0.0"

            

            user = User.objects.create_user(username=uname, email=email, password=password1)
            b = Manager(name=name, utxt=uname, email=email, ip=ip)
            b.save()


    

    return render(request, 'front/my_login.html')
Exemplo n.º 10
0
    def post(self, request):
        form = AddRestaurantForm(request.POST, request.FILES)
        data = dict(form=form)
        if form.is_valid():
            data = form.cleaned_data

            restaurant = Restaurant()
            manager = Manager()

            restaurant.name = data['name']
            restaurant.description = data['description']
            restaurant.profile_image = request.FILES['profile_image']

            manager.email = data['manager_email']
            chars = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"

            password = "".join([chars[ord(c) % len(chars)] for c in urandom(8)])
            manager.set_password(password)
            manager.is_confirmed = True
            manager.save()

            manager.send_email("Login details - Restaurant booking online",
                               "Your login details :\n E-mail : " + manager.email +
                               "\n Password : "******"\n You can login now " +
                               get_current_site(request).domain + "\n Restaurant booking online")

            restaurant.manager = manager
            restaurant.category = data['category']

            restaurant.save()

        return render(request, self.template_name, dict(form=form))
Exemplo n.º 11
0
def myregister(request):
    if request.method=='POST':
        name = request.POST.get('name')
        uname = request.POST.get('username')
        email = request.POST.get('email')
        pwd1 = request.POST.get('password1')
        pwd2 = request.POST.get('password2')

        if pwd1!=pwd2:
            msg = "Your passwords did'nt match "
            return render(request,'front/msgbox.html',{'msg':msg})

        if len(pwd1)<8:
                msg='Password must be atleast 8 characters long'
                return render(request,'front/msgbox.html',{'msg':msg})

        c1=0
        c2=0
        c3=0
        c4=0
        for i in pwd1:
            if i > "0" and i < "9":
                c1=1
            if i > "A" and i < "Z":
                c2=1
            if i > "a" and i < "z":
                c3=1
            if i > "!" and i < "(":
                c4=1
                
            if c1==0 and c2==0 and c3==0 and c4==0:
                msg='Password is not strong'
                return render(request,'front/msgbox.html',{'msg':msg})

    ip,is_routable= get_client_ip(request)
    if ip is None:
        ip="0.0.0.0"

    try:
        response = DbIpCity.get(ip,aip_keys='free') #we will get the country name only when the ip address is public
        country =response.country+'|'+response.city 

    except:
        country="unknown"

    #check if the entered username and email is already available or not
    if len(User.objects.filter(username=uname))==0 and len(User.objects.filter(email=email))==0:
        u = User.objects.create_user(username=uname,email=email,password=pwd1)
        b = Manager(name=name,uname=uname,email=email,ip=ip,country=country) 
        b.save()    

    return render(request,'front/login.html')
Exemplo n.º 12
0
def myRegister(request):
    if request.method == 'POST':
        name = request.POST.get('name')
        uname = request.POST.get('username')
        mail = request.POST.get('email')
        password = request.POST.get('password')
        ver_pass = request.POST.get('password-verify')
        if name == '':
            msg = "Your password didn't match"
            return render(request, 'front/msgbox.html', {'msg': msg})

        if password != ver_pass:
            msg = "Your password didn't match"
            return render(request, 'front/msgbox.html', {'msg': msg})

        #checking password strength
        count1 = 0
        count2 = 0
        count3 = 0
        count4 = 0
        for i in password:

            if i > "0" and i < "9":
                count1 = 1
            if i > "A" and i < "Z":
                count2 = 1
            if i > 'a' and i < 'z':
                count3 = 1
            if i > "!" and i < "(":
                count4 = 1
        if count1 == 0 and count2 == 0 and count3 == 0 and count4 == 0:
            msg = "Password has to be more strong"
            return render(request, 'front/msgbox.html', {'msg': msg})

        if len(password) < 8:
            msg = "Password has to be more than 8 character"
            return render(request, 'front/msgbox.html', {'msg': msg})

        #check if user already exists
        if len(User.objects.filter(username=uname)) == 0 and len(
                User.objects.filter(email=mail)) == 0:
            user = User.objects.create_user(username=uname,
                                            email=mail,
                                            password=password)
            #save data to custom user table
            b = Manager(name=name, utxt=uname, email=mail)
            b.save()

    return render(request, 'front/login.html')
Exemplo n.º 13
0
def user_loginout(req):
    if req.session.has_key('email'):
        del req.session['email']
        return render(req, 'login.html', {
            'manager': Manager.dummy_manager(),
            'msg': 'Logout...',
            'error': ''
        })
    else:
        return render(
            req, 'login.html', {
                'manager': Manager.dummy_manager(),
                'msg': '',
                'error': 'Login First...'
            })
Exemplo n.º 14
0
def myregister(request):

    if request.method == "POST":
        name = request.POST.get('name')
        uname = request.POST.get('uname')
        email = request.POST.get('email')
        password1 = request.POST.get('password1')
        password2 = request.POST.get('password2')

        if password1 != password2:
            msg = "Your password did not match"
            return render(request, 'front/msgbox.html', {'msg': msg})

        count1 = 0
        count2 = 0
        count3 = 0
        count4 = 0

        for i in password1:

            if i >= "0" and i <= "9":
                count1 = 1
            if i >= "A" and i <= "Z":
                count2 = 1
            if i >= "a" and i <= "z":
                count3 = 1
            if i >= "!" and i <= "(":
                count4 = 1

        print(count1, count2, count3, count4)
        if count1 == 0 and count2 == 0 and count3 == 0 and count4 == 0:
            msg = "Your password is not strong"
            return render(request, 'front/msgbox.html', {'msg': msg})

        if len(password1) < 8:
            msg = "Your password must be 8 Char"
            return render(request, 'front/msgbox.html', {'msg': msg})

        if len(User.objects.filter(username=uname)) == 0 and len(
                User.objects.filter(email=email)) == 0:

            user = User.objects.create_user(username=uname,
                                            email=email,
                                            password=password1)
            b = Manager(name=name, utxt=uname, email=email)
            b.save()

    return render(request, 'front/login.html')
Exemplo n.º 15
0
def failure(request):
    c = {}
    c.update(csrf(request))
    status = request.POST["status"]
    firstname = request.POST["firstname"]
    amount = request.POST["amount"]
    txnid = request.POST["txnid"]
    posted_hash = request.POST["hash"]
    key = request.POST["key"]
    productinfo = request.POST["productinfo"]
    email = request.POST["email"]
    salt = ""
    try:
        additionalCharges = request.POST["additionalCharges"]
        retHashSeq = additionalCharges + '|' + salt + '|' + status + '|||||||||||' + email + '|' + firstname + '|' + productinfo + '|' + amount + '|' + txnid + '|' + key
    except Exception:
        retHashSeq = salt + '|' + status + '|||||||||||' + email + '|' + firstname + '|' + productinfo + '|' + amount + '|' + txnid + '|' + key
    hashh = hashlib.sha512(retHashSeq.encode('utf-8')).hexdigest().lower()
    if (hashh != posted_hash):
        print("Invalid Transaction. Please try again")
    else:
        print("Thank You. Your order status is ", status)
        print("Your Transaction ID for this transaction is ", txnid)
        print("We have received a payment of Rs. ", amount,
              ". Your order will soon be shipped.")

    #create manager object
    manager = Manager(fName=firstname, email=email)
    return render(request, 'Failure.html', {
        "manager": manager,
        "txnid": txnid,
        "status": status,
        "amount": amount
    })
Exemplo n.º 16
0
def register_manager(request):
    if request.method == 'POST':
        new_manager = Manager(
            first_name=request.POST['first_name'],
            last_name=request.POST['last_name'],
            phone=request.POST['phone'],
            email=request.POST['email'],
            address=request.POST['address'],
            password=request.POST['password'],
        )
        new_manager.save()
        return HttpResponseRedirect(reverse('manager:login'))
    elif request.method == 'GET':
        template = 'manager/register.html'
        return render(request, template)
    return HttpResponse('Error: No se puede Guardar!')
Exemplo n.º 17
0
def Register(request):
    if request.method == 'POST':
        name = request.POST.get('name')
        uname = request.POST.get('uname')
        email = request.POST.get('email')
        password1 = request.POST.get('password1')
        password2 = request.POST.get('password2')
        if name == "":
            msg = "Please Input Your Name"
            return render(request, 'back/msgbox.html', {'msg': msg})
        if password1 != password2:
            msg = "Your Password Didn't Match"
            return render(request, 'back/msgbox.html', {'msg': msg})

        count1 = 0
        count2 = 0
        count3 = 0
        for i in password1:
            if "0" < i < "9":
                count1 = 1
            if "A" < i < "Z":
                count2 = 1
            if "a" < i < "z":
                count3 = 1

        if count1 == 0 or count2 == 0 or count3 == 0:
            msg = "Your Password Didn't Strong Enough"
            return render(request, 'back/msgbox.html', {'msg': msg})

        if len(password1) < 8:
            msg = "Your Password Must be Greater Than 8 Characters"
            return render(request, 'back/msgbox.html', {'msg': msg})

        if len(User.objects.filter(username=uname)) == 0 and len(
                User.objects.filter(email=email)) == 0:
            user = User.objects.create_user(username=uname,
                                            email=email,
                                            password=password1)
            b = Manager(name=name, utxt=uname, email=email)
            b.save()
        else:
            msg = "User already exists"
            return render(request, 'back/msgbox.html', {'msg': msg})

    return render(request, 'back/login.html')
Exemplo n.º 18
0
def user_register(request):
    global country
    if request.method == 'POST':
        name = request.POST.get('name')
        uname = request.POST.get('uname')
        uname = request.POST.get('uname')
        email = request.POST.get('email')
        password = request.POST.get('password')
        password_verify = request.POST.get('password-verify')
        # print(username, password, password_verify)

        if name == "":
            messages.error(request, "Vous devez saisir un nom")
            return redirect('register')

        if uname == "":
            messages.error(request, "Vous devez saisir un nom d'utilisateur")
            return redirect('register')

        if len(name) < 2:
            messages.error(request, "Votre nom doit comporter au moins 2 caractères")
            return redirect('register')

        if len(uname) < 2:
            messages.error(request, "Votre nom d'utilisateur doit comporter au moins 2 caractères")
            return redirect('register')

        try:
            validate_email(request.POST.get("email"))
        except ValidationError:
            messages.error(request, 'Entrez une adresse mail valide')
            return redirect('register')

        if password != password_verify:
            messages.error(request, "Les mots de passe saisis ne sont pas identiques")
            return redirect('register')

        count4 = 0
        count5 = 0
        count6 = 0

        for i in password:
            if '0' < i < '9':
                count4 += 1
            if 'A' < i < 'Z':
                count5 += 1
            if 'a' < i < 'z':
                count6 += 1

        if count4 == 0 or count5 == 0 or count6 == 0:
            messages.error(request,
                           "Votre mot de passe doit comporter au moins 8 caractères avec des chiffres, des lettres "
                           "minuscules et majuscules")
            return redirect('register')

        if len(password) < 8:
            messages.error(request, "Votre mot de passe doit comporter plus de 8 caractères")
            return redirect('register')

        if len(User.objects.filter(username=uname)) == 0 and len(User.objects.filter(email=email)) == 0:

            ip, is_routable = get_client_ip(request)

            if ip is None:

                ip = "0.0.0.0"

                try:
                    response = DbIpCity.get(ip, api_key='free')
                    country = response.country + " | " + response.city
                except:
                    country = "Unknown"

            user = User.objects.create_user(username=uname, email=email, password=password)
            b = Manager(name=name,
                        user_txt=uname,
                        email=email,
                        ip=ip,
                        # country=country,
                        # TODO A tester en prod
                        )
            b.save()

    return render(request, 'front/login.html')
Exemplo n.º 19
0
    def post(self, req):
        formdata = req.POST

        fName = formdata['firstname']
        lName = formdata['lastname']
        email = formdata['email']
        password = formdata['password']
        address = formdata['address']
        dob = formdata['dob']
        company = formdata['company']

        #if all fields empty
        if fName == "" or lName == "" or email == "" or password == "" or address == "" or dob == "" or company == "":
            return render(
                req, 'register.html', {
                    'manager': {
                        'fName': fName,
                        'lName': lName,
                        'email': email,
                        'address': address,
                        'dob': dob,
                        'company': company
                    },
                    'msg': '',
                    'error': 'Invalid Credentials...'
                })

        invalidFName = invalid_username(fName)  #check first name valid or not
        if invalidFName:
            return render(
                req, 'register.html', {
                    'manager': {
                        'fName': fName,
                        'lName': lName,
                        'email': email,
                        'address': address,
                        'dob': dob,
                        'company': company
                    },
                    'msg': '',
                    'error': 'Invalid First Name...'
                })

        invalidLName = invalid_username(lName)  #check last name valid or not
        if invalidLName:
            return render(
                req, 'register.html', {
                    'manager': {
                        'fName': fName,
                        'lName': lName,
                        'email': email,
                        'address': address,
                        'dob': dob,
                        'company': company
                    },
                    'msg': '',
                    'error': 'Invalid Last Name...'
                })

        invalidEmail = invalid_email(email)  #check email valid or not
        if invalidEmail:
            return render(
                req, 'register.html', {
                    'manager': {
                        'fName': fName,
                        'lName': lName,
                        'email': email,
                        'address': address,
                        'dob': dob,
                        'company': company
                    },
                    'msg': '',
                    'error': 'Invalid Email Id...'
                })

        duplicateEmail = duplicate_email(email)  #check email duplicate or not
        if duplicateEmail:
            return render(
                req, 'login.html', {
                    'manager': {
                        'fName': fName,
                        'lName': lName,
                        'email': email,
                        'address': address,
                        'dob': dob,
                        'company': company
                    },
                    'msg': '',
                    'error': 'User Already Exists...'
                })

        invalidDate = invalid_date(dob)  #check DOB valid or not
        if invalidDate:
            return render(
                req, 'register.html', {
                    'manager': {
                        'fName': fName,
                        'lName': lName,
                        'email': email,
                        'address': address,
                        'dob': dob,
                        'company': company
                    },
                    'msg': '',
                    'error': 'Invalid Date...'
                })

        invalidCompany = invalid_company(
            company)  #check company name valid or not
        if invalidCompany:
            return render(
                req, 'register.html', {
                    'manager': {
                        'fName': fName,
                        'lName': lName,
                        'email': email,
                        'address': address,
                        'dob': dob,
                        'company': company
                    },
                    'msg': '',
                    'error': 'Invalid Company Name...'
                })

        hash_pass = make_password(
            password)  # make_password is create encrypt password
        # print('-----------pass hash:', hash_pass)
        addManager = Manager(fName=fName,
                             lName=lName,
                             email=email,
                             password=hash_pass,
                             address=address,
                             dob=dob,
                             company=company)
        addManager.save()  #save manager registration

        return render(
            req, 'login.html', {
                'manager': addManager,
                'msg': 'User Registration Successfully...',
                'error': ''
            })  #after refistration go to login page
Exemplo n.º 20
0
 def get(self, req):
     return render(req, 'register.html', {
         'manager': Manager.dummy_manager(),
         'msg': '',
         'error': ''
     })
Exemplo n.º 21
0
def login(req):
    return render(req, 'login.html', {
        'manager': Manager.dummy_manager(),
        'msg': '',
        'error': ''
    })
Exemplo n.º 22
0
    def seed(self):
        for i in range(10):
            first_name = names.get_first_name()
            last_name = names.get_full_name()

            guest = Manager()
            guest.role = "GUEST"
            guest.email = "*****@*****.**" % str(i)
            guest.set_password('password')
            guest.first_name = first_name
            guest.last_name = last_name
            guest.is_active = True
            guest.is_confirmed = True
            guest.is_staff = False
            guest.is_superuser = False

            guest.save()
Exemplo n.º 23
0
def myregister(request):

    site = Main.objects.get(pk=2)

    if request.method == 'POST':
        name = request.POST.get('name')
        uname = request.POST.get('uname')
        email = request.POST.get('email')
        password1 = request.POST.get('password1')
        password2 = request.POST.get('password2')

        if name == '':
            msg = "Please enter your name..."
            return render(request,'front/msgbox.html',{'msg':msg,'site':site})

        if password1 != password2:
            msg = "The entered passwords are different!!"
            return render(request,'front/msgbox.html',{'msg':msg,'site':site})
        
        if len(password1)<8:
                msg = 'Password must contain atleast 8 characters.'
                return render(request,'front/msgbox.html',{'msg':msg,'site':site})

        c1,ca,cA=0,0,0

        for ch in password1:
            if ch in string.digits:
                c1=1
            if ch in string.ascii_lowercase:
                ca=1
            if ch in string.ascii_uppercase:
                cA=1
            
        if c1==0 or ca==0 or cA==0:
            msg = 'Password too weak!! Please enter a strong password.'
            return render(request,'front/msgbox.html',{'msg':msg,'site':site})

        
        if len(User.objects.filter(username=uname))==0 and len(User.objects.filter(password=password1))==0:
            
            ip, is_routable = get_client_ip(request)

            if ip is None :

                ip = "0.0.0.0"

            try :

                response = DbIpCity.get(ip,api_key='free')
                country = response.country + " | " + response.city

            except:

                country = "Unknown"

            user = User.objects.create_user(username=uname,email=email,password=password1)
            b = Manager(name=name,utxt=uname,email=email,ip=ip,country=country)
            b.save()
        

    return render(request, 'front/login.html')
Exemplo n.º 24
0
def myregister(request):

    if request.method == 'POST':

        name = request.POST.get('name')
        uname = request.POST.get('uname')
        email = request.POST.get('email')
        password1 = request.POST.get('password1')
        password2 = request.POST.get('password2')

        if name == "":
            msg = "Input Your Name"
            return render(request, 'front/msgbox.html', {'msg': msg})

        if password1 != password2:
            msg = "Your Password Didn't Match"
            return render(request, 'front/msgbox.html', {'msg': msg})

    #-# Check Password is Weak or Strong (by using count) Start #-#
        count1 = 0
        count2 = 0
        count3 = 0
        count4 = 0
        for i in password1:
            ## I defined here 4 counts
            ## if any user enter 10 char, count will change from 1 to 1 and it won't increase
            ## If my count 1 2 3 and 4 were all 1 then my password is a strong password
            if i > "0" and i < "9":
                count1 = 1  ## one number, count will change from 0 to 1
            if i > "A" and i < "Z":
                count2 = 1  ## one cap letter, count will change from 0 to 1
            if i > "a" and i < "z":
                count3 = 1  ## one small letter, count will change from 0 to 1
            if i > "!" and i < "(":
                count4 = 1  ## one sign, count will change from 0 to 1
            ## if enter number,cap,small,sign(count 1 1 1 1). if enter number,small(count 1 0 1 0) ##
        if count1 == 0 or count2 == 0 or count3 == 0 and count4 == 0:
            msg = "Your Password Is Not Strong Enough"
            return render(request, 'front/msgbox.html', {'msg': msg})
    #-# Check Password is Weak or Strong (by using count) End #-#
        if len(password1) < 8:
            msg = "Your Password Must Be At Least 8 Characters"
            return render(request, 'front/msgbox.html', {'msg': msg})

        if len(User.objects.filter(username=uname)) == 0 and len(
                User.objects.filter(email=email)) == 0:

            # Get User IP Start
            ip, is_routable = get_client_ip(request)

            if ip is None:
                ip = "0.0.0.0"
            # Get User IP End
            # Get User Location Start
            try:
                response = DbIpCity.get(ip, api_key='free')
                country = response.country + " | " + response.city

            except:
                country = "Unknown"
            # Get User Location End

            user = User.objects.create_user(username=uname,
                                            email=email,
                                            password=password1)
            b = Manager(name=name,
                        utxt=uname,
                        email=email,
                        ip=ip,
                        country=country)
            b.save()

    return render(request, 'front/login.html')
Exemplo n.º 25
0
def myregister(request):

    if request.method == 'POST':

        name = request.POST.get('name')
        uname = request.POST.get('uname')
        email = request.POST.get('email')
        password = request.POST.get('password')
        password1 = request.POST.get('password1')

        if name == "":
            msg = 'Name Field Is required'
            return render(request, 'front/message.html', {'msg': msg})

        if password != password1:
            msg = 'Password is wrong'
            return render(request, 'front/message.html', {'msg': msg})

        count1 = 0
        count2 = 0
        count3 = 0
        count4 = 0
        for i in password:
            if i > '0' and i < '9':
                count1 += 1
            if i > 'A' and i < 'Z':
                count2 += 1
            if i > 'a' and i < 'z':
                count3 += 1
            if i > '!' and i < ')':
                count4 += 1
        count = count1 + count2 + count3 + count4
        strength = len(password)
        if count >= 1 and strength < 8:
            msg = 'Weak Password'
            return render(request, 'front/message.html', {'msg': msg})

        if len(User.objects.filter(username=uname)) == 0 and len(
                User.objects.filter(email=email)) == 0:
            ip, is_routable = get_client_ip(request)

            if ip is None:
                ip = '0.0.0.0'
            # else:
            #     if is_routable:
            #         ipv = 'Public'
            #     else:
            #         ipv = 'Private'
            #
            # print(ip, ipv)

            try:
                response = DbIpCity.get(ip, api_key='free')
                country = response.country + '|' + response.city
            except:
                'Unknown Region'
            user = User.objects.create_user(username=uname,
                                            email=email,
                                            password=password)
            b = Manager(name=name,
                        uname=uname,
                        email=email,
                        ip=ip,
                        country=country)
            b.save()

    return render(request, 'front/login.html')
Exemplo n.º 26
0
def myregister(request):

    if request.method == "POST":

        uuser = request.POST.get("username")
        uemail = request.POST.get("email")
        upass = request.POST.get("pass")
        ucpass = request.POST.get("cpass")

        if uuser != "" and uemail != "" and upass != "" and ucpass != "":

            if upass != ucpass:

                txt = "The passwords don't match!"
                goback = "/register"
                return render(request, 'front/msgbox.html', {
                    'txt': txt,
                    'goback': goback
                })

            c1 = 0
            c2 = 0
            c3 = 0
            c4 = 0

            for c in upass:
                if c >= "0" and c <= "9":
                    c1 = 1
            for c in upass:
                if c >= "A" and c <= "Z":
                    c2 = 1
            for c in upass:
                if c >= "a" and c <= "z":
                    c3 = 1
            for c in upass:
                if c in '~!@#$%^&*()_+=-`':
                    c4 = 1

            if c1 == 0 or c2 == 0 or c3 == 0 or c4 == 0:

                txt = "The New Password should have at least 1 Capital Letter, 1 Small Letter, 1 Number and 1 Character!"
                goback = "/register"
                return render(request, 'front/msgbox.html', {
                    'txt': txt,
                    'goback': goback
                })

            if len(uuser) < 4:

                txt = "Your Username Must Be At Least 4 Characters!"
                goback = "/register"
                return render(request, 'front/msgbox.html', {
                    'txt': txt,
                    'goback': goback
                })

            if len(upass) < 8:

                txt = "Your Password Must Be At Least 8 Characters!"
                goback = "/register"
                return render(request, 'front/msgbox.html', {
                    'txt': txt,
                    'goback': goback
                })

            if len(User.objects.filter(username=uuser)) == 0 and len(
                    User.objects.filter(email=uemail)) == 0:

                user = User.objects.create_user(username=uuser,
                                                email=uemail,
                                                password=upass)
                b = Manager(uuser=uuser, uemail=uemail)
                b.save()

    return render(request, 'front/register.html')
Exemplo n.º 27
0
def myregister(request):

    if request.method == 'POST' :

        name = request.POST.get('name')
        username = request.POST.get('username')
        email    = request.POST.get('email')
        password = request.POST.get('password')
        confirm_password = request.POST.get('confirm_password')

        if password != confirm_password :

            msg = "Passwords don't match ! "
            messages.success(request, msg)

            return render(request, 'back/myregister.html')

        if len(password) < 8 :

            msg = "Password needs to be of at least 8 characters ! "
            messages.success(request, msg)

            return render(request, 'back/myregister.html')

        
        # c1, c2, c3, c4 = 0, 0, 0, 0

        # for i in password :

        #     if i > "0" and i < "9" :
        #         c1 = 1
        #     if i > "A" and i < "Z" :
        #         c1 = 1
        #     if i > "a" and i < "z" :
        #         c1 = 1
        #     if i > "!" and i < "(" :
        #         c1 = 1

        # if c1 == 0 or c2 == 0 or c3 == 0 or c4 == 0 :
        #     msg = "Password must contain at least 1 Uppercase, 1 Lowercase, 1 number and 1 Special character !"
        #     messages.success(request, msg)

        #     return render(request, 'back/myregister.html')



        if name != "" and username != "" and password != "" and password !="" and confirm_password != "" :

            if len(User.objects.filter(username=username)) == 0 and len(User.objects.filter(email=email)) == 0 :

                user = User.objects.create_user(username=username, email=email, password=password)
                obj = Manager(name=name, username=username, email=email)
                
                obj.save()

                return render(request, 'back/mylogin.html')

            else :

                msg = "User is taken, try putting different Username or Email ! "
                messages.success(request, msg)

                return render(request, 'back/myregister.html')
        else :

            msg = "Enter all the details ! "
            messages.success(request, msg)

            return render(request, 'back/myregister.html')



    return render(request, 'back/myregister.html')
Exemplo n.º 28
0
def myregister(request):

    if request.method == 'POST':

        name = request.POST.get('name')
        uname = request.POST.get('uname')
        email = request.POST.get('email')
        password1 = request.POST.get('password1')
        password2 = request.POST.get('password2')

        if name == '':
            msg = 'Input Your Name '
            return render(request , 'front/msgbox.html' , {'msg' : msg} )

        if password1 != password2:
            msg = 'Your Password Did Not Match '
            return render(request , 'front/msgbox.html' , {'msg' : msg} )

        count1 = 0
        count2 = 0
        count3 = 0
        count4 = 0

        for i in password1:

            if i > '0' and i < '9':
                count1 = 1
            if i > 'A' and i < 'Z':
                count2 = 1
            if i > 'a' and i < 'z':
                count3 = 1
            if i > '!' and  i < '(':
                count4 = 1

        if count1 == 0 or count2 == 0 or count3 == 0 or count4 == 0:
            msg = 'Your Password Is Not Strong '
            return render(request , 'front/msgbox.html' , {'msg' : msg} )

        if len(password1) < 8:
            msg = 'Your Password Most Be 8 Character '
            return render(request , 'front/msgbox.html' , {'msg' : msg} )

        if len(User.objects.filter(username = uname)) == 0 and len(User.objects.filter(email = email)) == 0:

            ip, is_routable = get_client_ip(request)

            if ip is None:

                ip = "0.0.0.0"

            try:

                response = DbIpCity.get(ip,api_key='free')
                country = response.country + ' | ' + response.city

            except :

                country = 'Unknown'

            user = User.objects.create_user(first_name = name , username = uname , email=email , password=password1)
            b = Manager(name=name , utxt=uname , email=email , ip=ip , country=country)
            b.save()

    return render(request , 'front/login.html')
Exemplo n.º 29
0
def register(request):

    if request.method == "POST":

        name = request.POST.get('name')
        uname = request.POST.get('uname')
        email = request.POST.get('email')
        regpassword = request.POST.get('regpassword')
        passwordverify = request.POST.get('passwordverify')

        if name == "":
            msg = "Name Feild Is Must"
            return render(request, 'front/msgbox.html', {'msg': msg})

        if regpassword != passwordverify:
            msg = "Password Is Not Mactching"
            return render(request, 'front/msgbox.html', {'msg': msg})

        SpecialSym = [
            '~', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '-', '+',
            '=', '|', '<', '>', ',', '.', '/', '?', '{', '}', '[', ']', ':',
            ':', "'"
        ]
        val = True

        if len(regpassword) < 8:
            error = "Password Must Be 8 Character"
            return render(request, 'back/error.html', {'error': error})

        if not any(char.isdigit() for char in regpassword):
            val = False
        if not any(char.isupper() for char in regpassword):
            val = False
        if not any(char.islower() for char in regpassword):
            val = False
        if not any(char in SpecialSym for char in regpassword):
            val = False

        if val == False:
            error = 'Password Must Contain Combination of Special Symbols'
            return render(request, 'back/error.html', {'error': error})

        if len(User.objects.filter(username=uname)) == 0 and len(
                User.objects.filter(email=email)) == 0:

            ip, is_routable = get_client_ip(request)
            if ip is None:
                ip = "0.0.0.0"
            else:
                if is_routable:
                    ipv = "Public"
                else:
                    ipv = "Private"

            print(ip, ipv)

            try:
                response = DbIpCity.get(ip, api_key='free')
                country = response.country + "|" + response.city
            except:
                country = 'Unknow'

            user = User.objects.create_user(username=uname,
                                            email=email,
                                            password=regpassword)
            b = Manager(name=name,
                        utxt=uname,
                        email=email,
                        ip=ip,
                        country=country)
            b.save()

    return render(request, 'front/login.html')
Exemplo n.º 30
0
def myregister(request, email, pk):
    if request.method == 'POST':
        name = request.POST.get('name')
        lastname = request.POST.get('lastname')
        tokenn = request.POST.get('tokenn')
        utext = request.POST.get('utext')
        pass1 = request.POST.get('pass1')
        pass2 = request.POST.get('pass2')
        a = Token.objects.get(pk=pk).token
        if not str(tokenn) == str(a):
            msg = "Your input token is invalid"
            return render(request, 'front/msgbox.html', {'msg': msg})
        if pass1 != pass2:
            msg = "Your Pass Didn't Match"
            return render(request, 'front/msgbox.html', {'msg': msg})
        count1 = 0
        count2 = 0
        #count3 = 0
        #count4 = 0

        for i in pass1:

            if i > "0" and i < "9":
                count1 = 1
            if (i > "A" and i < "Z") or (i > 'a' and i < 'z'):
                count2 = 1

            #if i > "!" and i < "(" :
            #count4 = 1

        if count1 == 0 or count2 == 0:
            msg = "Your Pass Is Not Strong"
            return render(request, 'front/msgbox.html', {'msg': msg})

        if len(pass1) < 8:
            msg = "Your Pass Most Be 8 Character"
            return render(request, 'front/msgbox.html', {'msg': msg})
        if len(User.objects.filter(username=utext)) == 0 and len(
                User.objects.filter(email=email)) == 0:
            ip, is_routable = get_client_ip(request)
            if ip is None:
                ip = '0.0.0.0'

            user = User.objects.create_user(username=utext,
                                            password=pass1,
                                            email=email)
            b = Manager(name=name,
                        lastname=lastname,
                        email=email,
                        utext=utext,
                        ip=ip)
            b.save()

            user1 = authenticate(username=utext, password=pass1)
            if user1 != None:
                login(request, user1)
                return redirect('home')

        else:
            msg = "this username or email is already exist"
            return render(request, 'front/msgbox.html', {'msg': msg})

    return render(request, 'front/myregister.html', {'pk': pk, 'email': email})