-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added password security level with a bar. #182
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
|
||
.password-wrapper { | ||
height: 45px; | ||
width: 100%; | ||
display: flex; | ||
position: relative; | ||
} | ||
form .password-wrapper .password{ | ||
width: 100%; | ||
height: 100%; | ||
border: 1px solid lightgrey; | ||
outline: none; | ||
border-radius: 5px; | ||
font-size: 17px; | ||
transition: all 0.3s; | ||
} | ||
form .password-wrapper input:focus{ | ||
border-color: #27ae60; | ||
box-shadow: inset 0 0 3px #2fd072; | ||
} | ||
form .password-wrapper .showBtn{ | ||
position: absolute; | ||
right: 10px; | ||
top: 50%; | ||
transform: translateY(-50%); | ||
font-size: 15px; | ||
font-weight: 600; | ||
cursor: pointer; | ||
display: none; | ||
user-select: none; | ||
} | ||
form .indicator{ | ||
height: 10px; | ||
margin: 5px 10px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
display: none; | ||
} | ||
form .indicator span{ | ||
position: relative; | ||
height: 100%; | ||
width: 100%; | ||
background: lightgrey; | ||
border-radius: 5px; | ||
} | ||
form .indicator span:nth-child(2){ | ||
margin: 0 3px; | ||
} | ||
form .indicator span.active:before{ | ||
position: absolute; | ||
content: ''; | ||
top: 0; | ||
left: 0; | ||
height: 100%; | ||
width: 100%; | ||
border-radius: 5px; | ||
} | ||
.indicator span.weak:before{ | ||
background-color: #ff4757; | ||
} | ||
.indicator span.medium:before{ | ||
background-color: orange; | ||
} | ||
.indicator span.strong:before{ | ||
background-color: #23ad5c; | ||
} | ||
form .text{ | ||
font-size: 20px; | ||
font-weight: 500; | ||
position: relative; | ||
display: none; | ||
margin-bottom: -10px; | ||
} | ||
form .text.weak{ | ||
color: #ff4757; | ||
} | ||
form .text.medium{ | ||
color: orange; | ||
} | ||
form .text.strong{ | ||
color: #23ad5c; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
const indicator = document.querySelector(".indicator"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a better name for classes so that it doesn't conflict with some other variables in future. like instead of |
||
const input = document.querySelector(".password"); | ||
const weak = document.querySelector(".weak"); | ||
const medium = document.querySelector(".medium"); | ||
const strong = document.querySelector(".strong"); | ||
const text = document.querySelector(".text"); | ||
const showBtn = document.querySelector(".showBtn"); | ||
let regExpWeak = /[a-z]/; | ||
let regExpMedium = /\d+/; | ||
let regExpStrong = /.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/; | ||
function trigger(){ | ||
if(input.value != ""){ | ||
indicator.style.display = "block"; | ||
indicator.style.display = "flex"; | ||
if(input.value.length <= 3 && (input.value.match(regExpWeak) || input.value.match(regExpMedium) || input.value.match(regExpStrong)))no=1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make this code a bit better readable, like you can do one thing. It would be better with some spaces and line breaks |
||
if(input.value.length >= 6 && ((input.value.match(regExpWeak) && input.value.match(regExpMedium)) || (input.value.match(regExpMedium) && input.value.match(regExpStrong)) || (input.value.match(regExpWeak) && input.value.match(regExpStrong))))no=2; | ||
if(input.value.length >= 6 && input.value.match(regExpWeak) && input.value.match(regExpMedium) && input.value.match(regExpStrong))no=3; | ||
if(no==1){ | ||
weak.classList.add("active"); | ||
text.style.display = "block"; | ||
text.textContent = "Your password is too week"; | ||
text.classList.add("weak"); | ||
} | ||
if(no==2){ | ||
medium.classList.add("active"); | ||
text.textContent = "Your password is medium"; | ||
text.classList.add("medium"); | ||
}else{ | ||
medium.classList.remove("active"); | ||
text.classList.remove("medium"); | ||
} | ||
if(no==3){ | ||
weak.classList.add("active"); | ||
medium.classList.add("active"); | ||
strong.classList.add("active"); | ||
text.textContent = "Your password is strong"; | ||
text.classList.add("strong"); | ||
}else{ | ||
strong.classList.remove("active"); | ||
text.classList.remove("strong"); | ||
} | ||
showBtn.style.display = "block"; | ||
showBtn.onclick = function(){ | ||
if(input.type == "password"){ | ||
input.type = "text"; | ||
showBtn.textContent = "HIDE"; | ||
showBtn.style.color = "#23ad5c"; | ||
}else{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, proper formatting is just needed. |
||
input.type = "password"; | ||
showBtn.textContent = "SHOW"; | ||
showBtn.style.color = "#000"; | ||
} | ||
} | ||
}else{ | ||
indicator.style.display = "none"; | ||
text.style.display = "none"; | ||
showBtn.style.display = "none"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> | ||
<link rel="stylesheet" type="text/css" href="/css/signin.css"> | ||
<link rel="stylesheet" href="path/to/font-awesome/css/font-awesome.min.css"> | ||
<link rel="stylesheet" href="/css/passwordindicator.css"> | ||
</head> | ||
|
||
<style> | ||
|
@@ -130,6 +131,7 @@ | |
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
|
||
<form action="/user/signup" method="post" class="form-signin" id ="signupform"> | ||
<img class="mb-4" src="/photos/avatar.png" alt="" width="72" height="72"> | ||
<h1 class="h3 mb-3 font-weight-normal">Sign Up</h1> | ||
|
@@ -139,15 +141,26 @@ | |
<input type="text" name="name" id="inputName" class="form-control" placeholder="Name" required autofocus> | ||
<label for="email" class="sr-only">Email</label> | ||
<input type="email" name="email" id="inputEmailSignUp" class="form-control" placeholder="Email" required autofocus> | ||
<label for="inputPasswordSignUp" class="sr-only">Password</label> | ||
<input type="password" name="password" id="inputPasswordSignUp" class="form-control" placeholder="Password" required> | ||
|
||
<div class="password-wrapper"> | ||
<label for="inputPasswordSignUp" class="sr-only">Password</label> | ||
<input class="form-control password" type="password" onkeyup="trigger()" name="password" id="inputPasswordSignUp" placeholder="Password" required> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice work! |
||
<span class="showBtn">SHOW</span> | ||
</div> | ||
<div class="indicator"> | ||
<span class="weak"></span> | ||
<span class="medium"></span> | ||
<span class="strong"></span> | ||
</div> | ||
<div class="text"></div> | ||
|
||
<label for="inputPasswordSignUp" class="sr-only">Confirm Password</label> | ||
<input type="password" name="password2" id="inputPasswordSignUp2" class="form-control" placeholder="Confirm Password" required> | ||
<input type="submit" name="" class="btn btn-lg btn-primary btn-block" type="submit" value="Sign Up"> | ||
<p class="mt-5 mb-3 text-muted">Already have an Account? <a class="close-modal" data-toggle="modal" href="#loginModal"> Sign In Now!</a></p> | ||
<label id="errormsg2" class="errmsg"></label> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<script | ||
|
@@ -157,4 +170,5 @@ | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> | ||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> | ||
<script src="/js/modals_change.js"></script> | ||
<script src="https://www.kryogenix.org/code/browser/sorttable/sorttable.js"></script> | ||
<script src="https://www.kryogenix.org/code/browser/sorttable/sorttable.js"></script> | ||
<script src="/js/passwordindicator.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, it will be better if you add a single line after the ending of each css block