mirror of
https://github.com/Nezumi-2711/javascript-training.git
synced 2026-09-23 04:09:58 +00:00
Fix name of variable constant file and format code
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
export const DATABASE_URL =
|
||||||
|
'https://javascript-training-81f7a-default-rtdb.asia-southeast1.firebasedatabase.app';
|
||||||
|
export const TIME_OUT_SEC = 3;
|
||||||
|
export const REGEX_PASSWORD =
|
||||||
|
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
export const databaseURL =
|
export const MESSAGE = {
|
||||||
'https://javascript-training-81f7a-default-rtdb.asia-southeast1.firebasedatabase.app';
|
PASSWORD_NOT_MATCH: 'Password not match! Please try again!',
|
||||||
export const regex =
|
PASSWORD_NOT_STRONG:
|
||||||
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/;
|
'Password must at least one uppercase, one lowercase letter, one number and one special character!',
|
||||||
export const PASSWORD_NOT_MATCH = 'Password not match! Please try again!';
|
ERROR_MESSAGE_DEFAULT: 'Something went wrong!',
|
||||||
export const PASSWORD_NOT_STRONG =
|
};
|
||||||
'Password must at least one uppercase, one lowercase letter, one number and one special character!';
|
|
||||||
export const ERROR_MESSAGE_DEFAULT = 'Something went wrong!';
|
|
||||||
export const TIME_OUT_SEC = 3;
|
|
||||||
export const TIME_OUT_ERROR = {
|
export const TIME_OUT_ERROR = {
|
||||||
status: 408,
|
status: 408,
|
||||||
message: 'Connection time out! Please try again!',
|
message: 'Connection time out! Please try again!',
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
import { TIME_OUT_SEC, TIME_OUT_ERROR, regex } from '../constants/constant';
|
import {
|
||||||
|
TIME_OUT_SEC,
|
||||||
|
TIME_OUT_ERROR,
|
||||||
|
REGEX_PASSWORD,
|
||||||
|
} from '../constants/constant';
|
||||||
import FirebaseService from '../services/firebaseService';
|
import FirebaseService from '../services/firebaseService';
|
||||||
|
|
||||||
export const validatePassword = (password) => {
|
export const validatePassword = (password) => {
|
||||||
return regex.test(password);
|
return REGEX_PASSWORD.test(password);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const timeout = (s) => {
|
export const timeout = (s) => {
|
||||||
@@ -13,10 +17,6 @@ export const timeout = (s) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createIdUser = () => {
|
|
||||||
return new Date().getTime();
|
|
||||||
};
|
|
||||||
|
|
||||||
export const timeOutConnect = async (action) => {
|
export const timeOutConnect = async (action) => {
|
||||||
const result = await Promise.race([action, timeout(TIME_OUT_SEC)]);
|
const result = await Promise.race([action, timeout(TIME_OUT_SEC)]);
|
||||||
|
|
||||||
|
|||||||
@@ -4,4 +4,8 @@ export default class User {
|
|||||||
this.password = password;
|
this.password = password;
|
||||||
this.walletName = walletName;
|
this.walletName = walletName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static createIdUser() {
|
||||||
|
return new Date().getTime();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import {
|
|||||||
goOnline,
|
goOnline,
|
||||||
onValue,
|
onValue,
|
||||||
} from 'firebase/database';
|
} from 'firebase/database';
|
||||||
import { databaseURL } from '../constants/constant';
|
import { DATABASE_URL } from '../constants/config';
|
||||||
|
|
||||||
class FirebaseService {
|
class FirebaseService {
|
||||||
constructor() {
|
constructor() {
|
||||||
const firebaseConfig = {
|
const firebaseConfig = {
|
||||||
databaseURL,
|
DATABASE_URL,
|
||||||
};
|
};
|
||||||
this.app = initializeApp(firebaseConfig);
|
this.app = initializeApp(firebaseConfig);
|
||||||
this.db = getDatabase(this.app);
|
this.db = getDatabase(this.app);
|
||||||
@@ -36,8 +36,11 @@ class FirebaseService {
|
|||||||
ref(this.db, path),
|
ref(this.db, path),
|
||||||
(snapshot) => {
|
(snapshot) => {
|
||||||
let result = false;
|
let result = false;
|
||||||
|
|
||||||
|
// snapshot is a type of data by Firebase define
|
||||||
snapshot.forEach((childSnapshot) => {
|
snapshot.forEach((childSnapshot) => {
|
||||||
const data = childSnapshot.val();
|
const data = childSnapshot.val();
|
||||||
|
|
||||||
if (data[property] === value) {
|
if (data[property] === value) {
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<link rel="stylesheet" href="../styles/_main.scss" />
|
|
||||||
<title>Register - Money Lover</title>
|
<title>Register - Money Lover</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -55,6 +54,6 @@
|
|||||||
<!-- End form -->
|
<!-- End form -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="module" src="../js/main.js"></script>
|
<script type="module" src="../js/controller.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user