From ca35a8ca8bf758663e4139972bc7a358f25e2bd8 Mon Sep 17 00:00:00 2001
From: Yichen <33232314+yidu2008@users.noreply.github.com>
Date: Thu, 26 Mar 2020 21:01:40 -0400
Subject: [PATCH] Mar 26 21:01
Finished logic and started work with meter
---
src/app/tab2/tab2.page.html | 20 ++++-
src/app/tab2/tab2.page.scss | 7 +-
src/app/tab2/tab2.page.ts | 174 ++++++++++++++++++++++++++++++++++--
3 files changed, 187 insertions(+), 14 deletions(-)
diff --git a/src/app/tab2/tab2.page.html b/src/app/tab2/tab2.page.html
index 10775e2..04dcf2a 100644
--- a/src/app/tab2/tab2.page.html
+++ b/src/app/tab2/tab2.page.html
@@ -15,11 +15,23 @@
Run Program
+
+ Please note that although our program will only test a few things, keep
+ these things in mind:
+
+
+ Never, ever, ever use your personal information.
+
+
+ Try not to use dictionary words.
+
Strength Meter:
-
+
diff --git a/src/app/tab2/tab2.page.scss b/src/app/tab2/tab2.page.scss
index 902cec3..c7bf545 100644
--- a/src/app/tab2/tab2.page.scss
+++ b/src/app/tab2/tab2.page.scss
@@ -2,7 +2,10 @@ ion-content ion-toolbar {
--background: translucent;
}
-.meter-display {
- height: 1em;
+.meter-display-container {
border: 1px solid black;
+ background-color: grey;
+ .meter-display {
+ height: 1em;
+ }
}
\ No newline at end of file
diff --git a/src/app/tab2/tab2.page.ts b/src/app/tab2/tab2.page.ts
index 141cb83..083857f 100644
--- a/src/app/tab2/tab2.page.ts
+++ b/src/app/tab2/tab2.page.ts
@@ -10,6 +10,7 @@ import { ToastController } from "@ionic/angular";
export class Tab2Page {
public password = new FormControl("");
public meterStrengthColor = "darkgreen";
+ public meterStrengthWidth = 0;
constructor(public toastController: ToastController) {}
@@ -19,36 +20,193 @@ export class Tab2Page {
console.log(this.password.value.length);
- if (this.password.value.length < 7) {
+ if (this.password.value.length < 7 && this.password.value.length > 0) {
console.log("Your password is very short!");
alertMessages.push("Your password is very short!");
+ this.meterStrengthWidth = this.meterStrengthWidth + 12.5;
}
+ this.meterStrengthWidth = 5;
if (this.password.value.length > 6 && this.password.value.length < 12) {
console.log("Your password is short!");
- alertMessages.push("Your password is short!");
+ alertMessages.push("Your password is short!");
+ this.meterStrengthWidth = this.meterStrengthWidth + 25;
}
if (this.password.value.length > 11) {
console.log("Your password is long enough. Now, will you remember it?");
alertMessages.push(
"Your password is long enough. Now, will you remember it?"
);
+ this.meterStrengthWidth = this.meterStrengthWidth + 50;
}
if (this.password.value.length < 1) {
console.log("You didn't enter a password!");
alertMessages.push("You didn't enter a password!");
+ this.meterStrengthWidth = this.meterStrengthWidth + 0;
}
if (/^[a-zA-Z]+$/gi.test(this.password.value)) {
console.log("Your password contains only letters. This isn't good!");
alertMessages.push(
"Your password contains only letters. This isn't good!"
);
+ this.meterStrengthWidth = this.meterStrengthWidth + 25;
}
- if (alertMessages.length > 0) {
- const toast = await this.toastController.create({
- message: alertMessages.join("\n"),
- duration: 5000
- });
- toast.present();
+ if (/^[a-z]+$/g.test(this.password.value)) {
+ console.log(
+ "Your password contains only lowercase letters. Try adding uppercase letters!"
+ );
+ alertMessages.push(
+ "Your password contains only lowercase letters. Try adding uppercase letters!"
+ );
+ this.meterStrengthWidth = this.meterStrengthWidth + 25;
+ }
+ if (/^[A-Z]+$/g.test(this.password.value)) {
+ console.log(
+ "Your password contains only uppercase letters. Try adding lowercase letters!"
+ );
+ alertMessages.push(
+ "Your password contains only uppercase letters. Try adding lowercase letters!"
+ );
+ this.meterStrengthWidth = this.meterStrengthWidth + 25;
+ }
+ if (/^[0-9]+$/g.test(this.password.value)) {
+ console.log("Your password contains only numbers. This isn't good!");
+ alertMessages.push(
+ "Your password contains only numbers. This isn't good!"
+ );
+ this.meterStrengthWidth = this.meterStrengthWidth + 25;
+ if (/^[a-zA-Z0-9!-)]+$/g.test(this.password.value)) {
+ console.log(
+ "Your password contains good content. Now, will you remember it?"
+ );
+ alertMessages.push(
+ "Your password contains good content. Now, will you remember it?"
+ );
+ this.meterStrengthWidth = this.meterStrengthWidth + 50;
+ }
+ if (/password/gi.test(this.password.value)) {
+ console.log(
+ "Your password contains the word password. This is a very bad decision!"
+ );
+ alertMessages.push(
+ "Your password contains the word password. This is a very bad decision!"
+ );
+ }
+ if (/^123456+$/gi.test(this.password.value)) {
+ console.log(
+ "Your password is 123456, the most common password. This is a very unsecure password!"
+ );
+ alertMessages.push(
+ "Your password is 123456, the most common password. This is a very unsecure password!"
+ );
+ this.meterStrengthWidth = this.meterStrengthWidth - 100;
+ }
+
+ if (/^123456789+$/gi.test(this.password.value)) {
+ console.log(
+ "Your password is 123456789, the 2nd most common password. This is a very unsecure password!"
+ );
+ alertMessages.push(
+ "Your password is 123456789, the 2nd most common password. This is a very unsecure password!"
+ );
+ this.meterStrengthWidth = this.meterStrengthWidth - 100;
+ }
+ if (/^qwerty+$/gi.test(this.password.value)) {
+ console.log(
+ "Your password is qwerty, the 3rd most common password. This is a very unsecure password!"
+ );
+ alertMessages.push(
+ "Your password is qwerty, the 3rd most common password. This is a very unsecure password!"
+ );
+ this.meterStrengthWidth = this.meterStrengthWidth - 100;
+ }
+ if (/^password+$/gi.test(this.password.value)) {
+ console.log(
+ "Your password is password, the 4th most common password. This is a very unsecure password!"
+ );
+ alertMessages.push(
+ "Your password is password, the 4th most common password. This is a very unsecure password!"
+ );
+ this.meterStrengthWidth = this.meterStrengthWidth - 100;
+ }
+ if (/^1234567+$/gi.test(this.password.value)) {
+ console.log(
+ "Your password is 1234567, the 5th most common password. This is a very unsecure password!"
+ );
+ alertMessages.push(
+ "Your password is 1234567, the 5th most common password. This is a very unsecure password!"
+ );
+ this.meterStrengthWidth = this.meterStrengthWidth - 100;
+ }
+ if (/^12345678+$/gi.test(this.password.value)) {
+ console.log(
+ "Your password is 12345678, the 6th most common password. This is a very unsecure password!"
+ );
+ alertMessages.push(
+ "Your password is 12345678, the 6th most common password. This is a very unsecure password!"
+ );
+ this.meterStrengthWidth = this.meterStrengthWidth - 100;
+ }
+ if (/^12345+$/gi.test(this.password.value)) {
+ console.log(
+ "Your password is 12345, the 7th most common password. This is a very unsecure password!"
+ );
+ alertMessages.push(
+ "Your password is 12345, the 7th most common password. This is a very unsecure password!"
+ );
+ this.meterStrengthWidth = this.meterStrengthWidth - 100;
+ }
+ if (/^iloveyou+$/gi.test(this.password.value)) {
+ console.log(
+ "Your password is iloveyou, the 8th most common password. This is a very unsecure password!"
+ );
+ alertMessages.push(
+ "Your password is iloveyou, the 8th most common password. This is a very unsecure password!"
+ );
+ this.meterStrengthWidth = this.meterStrengthWidth - 100;
+ }
+ if (/^111111+$/gi.test(this.password.value)) {
+ console.log(
+ "Your password is 111111, the 9th most common password. This is a very unsecure password!"
+ );
+ alertMessages.push(
+ "Your password is 111111, the 9th most common password. This is a very unsecure password!"
+ );
+ this.meterStrengthWidth = this.meterStrengthWidth - 100;
+ }
+ if (/^123123+$/gi.test(this.password.value)) {
+ console.log(
+ "Your password is 123123, the 10th most common password. This is a very unsecure password!"
+ );
+ alertMessages.push(
+ "Your password is 123123, the 10th most common password. This is a very unsecure password!"
+ );
+ this.meterStrengthWidth = this.meterStrengthWidth - 100;
+ }
+ if (alertMessages.length > 0) {
+ const toast = await this.toastController.create({
+ message: alertMessages.join("\n"),
+ duration: 5000
+ });
+ toast.present();
+ }
+ if (this.meterStrengthWidth === 100) {
+ this.meterStrengthColor = "darkgreen";
+ }
+ if (this.meterStrengthWidth < 100 && this.meterStrengthWidth > 75) {
+ this.meterStrengthColor = "green";
+ }
+ if (this.meterStrengthWidth < 75 && this.meterStrengthWidth > 50) {
+ this.meterStrengthColor = "yellow";
+ }
+ if (this.meterStrengthWidth < 50 && this.meterStrengthWidth > 25) {
+ this.meterStrengthColor = "orange";
+ }
+ if (this.meterStrengthWidth < 25 && this.meterStrengthWidth > 10) {
+ this.meterStrengthColor = "red";
+ }
+ if (this.meterStrengthWidth < 10) {
+ this.meterStrengthColor = "darkred";
+ }
}
}
}