mirror of
https://github.com/Nezumi-2711/javascript-training.git
synced 2026-09-22 13:38:43 +00:00
Merge code from feat/javascript-practice branch
This commit is contained in:
@@ -3,5 +3,6 @@ import App from './app';
|
||||
// Sure that scripts called after DOM loaded
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const myApp = new App();
|
||||
|
||||
myApp.start();
|
||||
});
|
||||
|
||||
@@ -19,12 +19,14 @@ export default class CommonService {
|
||||
value,
|
||||
);
|
||||
const result = await timeOutConnect(existUser);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async save(data, path = this.defaultPath) {
|
||||
this.connectToDb();
|
||||
const saveUser = this.firebaseService.save(data, path);
|
||||
|
||||
await timeOutConnect(saveUser);
|
||||
}
|
||||
|
||||
@@ -32,7 +34,9 @@ export default class CommonService {
|
||||
this.connectToDb();
|
||||
const result = await this.firebaseService.getDataFromId(id, path);
|
||||
const data = await timeOutConnect(result);
|
||||
|
||||
if (data) return data;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ export default class UserService extends CommonService {
|
||||
*/
|
||||
saveUser(user) {
|
||||
const pathData = this.defaultPath + User.createIdUser();
|
||||
|
||||
this.save(user, pathData);
|
||||
}
|
||||
|
||||
@@ -34,9 +35,11 @@ export default class UserService extends CommonService {
|
||||
*/
|
||||
async checkUserExist(email) {
|
||||
const userExist = await this.getUserIdByEmail(email);
|
||||
|
||||
if (userExist) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -47,10 +50,13 @@ export default class UserService extends CommonService {
|
||||
*/
|
||||
async getUserByEmail(email) {
|
||||
const id = await this.getUserIdByEmail(email);
|
||||
|
||||
if (id) {
|
||||
const user = await this.getDataFromId(id);
|
||||
|
||||
return new User(user);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,10 @@ export default class RegisterView extends CommonLoginRegisterView {
|
||||
|
||||
if (this.validateForm(account)) {
|
||||
const user = new User(account);
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user