Fakultas Ilmu Komputer UI

Commit 6ad882bc authored by Muhammad Ilham Peruzzi's avatar Muhammad Ilham Peruzzi
Browse files

1606823475-98

parent 820bb174
......@@ -7,11 +7,23 @@ describe('CompanyRegisterModal', () => {
const lowerCaseLetters = /[a-z]/g;
const upperCaseLetters = /[A-Z]/g;
const numbers = /[0-9]/g;
if(password.length < 8) return "Password less than 8"; else
if(!lowerCaseLetters.test(password)) return "Password at least one lowercase letter"; else
if(!upperCaseLetters.test(password)) return "Password at least one uppercase letter"; else
if(!numbers.test(password)) return "Password at least one number";
else return true
if(password.length < 8) {
return "Password less than 8";
} else {
if(!lowerCaseLetters.test(password)) {
return "Password at least one lowercase letter";
}
if(!upperCaseLetters.test(password)) {
return "Password at least one uppercase letter";
}
if(!numbers.test(password)) {
return "Password at least one number";
}
return true
}
}
it('renders without problem', () => {
......
......@@ -71,12 +71,22 @@ export default class CompanyRegisterModal extends React.Component {
handlePassword = (e) => {
if (e.target.name === 'password') this.passwordField = e.target; else
if (e.target.name === 'password-confirm') this.passwordConfirmField = e.target;
if (e.target.name === 'password') {
this.passwordField = e.target;
} else if (e.target.name === 'password-confirm') {
this.passwordConfirmField = e.target;
}
const validatePassword = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}/g;
if(!validatePassword.test(this.passwordField.value)) this.passwordField.setCustomValidity("Must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters");
else this.passwordField.setCustomValidity("");
if(!validatePassword.test(this.passwordField.value)) {
this.passwordField.setCustomValidity("Must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters");
} else {
this.passwordField.setCustomValidity("");
}
const isExist = this.passwordField && this.passwordConfirmField;
if (isExist) {
if (this.passwordField.value !== this.passwordConfirmField.value) {
this.passwordConfirmField.setCustomValidity("Passwords Don't Match");
......
......@@ -24,13 +24,20 @@ export default class App extends React.Component {
const data = Storage.get('user-data');
if (data.is_staff) {
return 'admin';
} if (data.supervisor) {
}
if (data.supervisor) {
return 'supervisor';
} if (data.student) {
}
if (data.student) {
return 'student';
} if (data.company) {
}
if (data.company) {
return 'company';
}
return 'error';
}
return 'not-logged-in';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment