mirror of
https://github.com/Nezumi-2711/javascript-training.git
synced 2026-09-22 20:01:31 +00:00
Format code
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,19 +19,23 @@ export default class CommonService {
|
||||
value,
|
||||
);
|
||||
const result = await timeOutConnect(existUser);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async save(data, path = this.path) {
|
||||
this.connectToDb();
|
||||
const saveUser = this.firebaseService.save(data, path);
|
||||
|
||||
await timeOutConnect(saveUser);
|
||||
}
|
||||
|
||||
async getDataFromId(id, path = this.path) {
|
||||
this.connectToDb();
|
||||
const data = await this.firebaseService.getDataFromId(id, path);
|
||||
|
||||
if (data) return data;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ export default class UserService extends CommonService {
|
||||
*/
|
||||
saveUser(user) {
|
||||
const pathData = this.defaultPath + User.createIdUser();
|
||||
|
||||
this.save(user, pathData);
|
||||
}
|
||||
|
||||
@@ -33,9 +34,11 @@ export default class UserService extends CommonService {
|
||||
*/
|
||||
async checkUserExist(email) {
|
||||
const userExist = await this.getUserIdByEmail(email);
|
||||
|
||||
if (userExist) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -46,10 +49,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