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