added crypto-es & bugfixes translation
This commit is contained in:
parent
97348d048f
commit
176e2cfa35
8 changed files with 64 additions and 25 deletions
6
package-lock.json
generated
6
package-lock.json
generated
|
|
@ -21,6 +21,7 @@
|
||||||
"@ctrl/ngx-emoji-mart": "^9.2.0",
|
"@ctrl/ngx-emoji-mart": "^9.2.0",
|
||||||
"@ngx-translate/core": "^15.0.0",
|
"@ngx-translate/core": "^15.0.0",
|
||||||
"@ngx-translate/http-loader": "^8.0.0",
|
"@ngx-translate/http-loader": "^8.0.0",
|
||||||
|
"crypto-es": "^2.1.0",
|
||||||
"ng2-pdf-viewer": "^10.0.0",
|
"ng2-pdf-viewer": "^10.0.0",
|
||||||
"ngx-extended-pdf-viewer": "^19.6.6",
|
"ngx-extended-pdf-viewer": "^19.6.6",
|
||||||
"rxjs": "~7.8.0",
|
"rxjs": "~7.8.0",
|
||||||
|
|
@ -6106,6 +6107,11 @@
|
||||||
"node": ">= 8"
|
"node": ">= 8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/crypto-es": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/crypto-es/-/crypto-es-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-C5Dbuv4QTPGuloy5c5Vv/FZHtmK+lobLAypFfuRaBbwCsk3qbCWWESCH3MUcBsrgXloRNMrzwUAiPg4U6+IaKA=="
|
||||||
|
},
|
||||||
"node_modules/css-loader": {
|
"node_modules/css-loader": {
|
||||||
"version": "6.10.0",
|
"version": "6.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/css-loader/-/css-loader-6.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/css-loader/-/css-loader-6.10.0.tgz",
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
"@ctrl/ngx-emoji-mart": "^9.2.0",
|
"@ctrl/ngx-emoji-mart": "^9.2.0",
|
||||||
"@ngx-translate/core": "^15.0.0",
|
"@ngx-translate/core": "^15.0.0",
|
||||||
"@ngx-translate/http-loader": "^8.0.0",
|
"@ngx-translate/http-loader": "^8.0.0",
|
||||||
|
"crypto-es": "^2.1.0",
|
||||||
"ng2-pdf-viewer": "^10.0.0",
|
"ng2-pdf-viewer": "^10.0.0",
|
||||||
"ngx-extended-pdf-viewer": "^19.6.6",
|
"ngx-extended-pdf-viewer": "^19.6.6",
|
||||||
"rxjs": "~7.8.0",
|
"rxjs": "~7.8.0",
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,4 @@ import { ToggleBooleanService } from './service/toggle-boolean.service';
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
title = 'dabubble';
|
title = 'dabubble';
|
||||||
|
|
||||||
constructor(public toggleAllBooleans:ToggleBooleanService){}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ export class MainComponent {
|
||||||
* Checks if the user is logged in.
|
* Checks if the user is logged in.
|
||||||
*/
|
*/
|
||||||
ifUserLogin() {
|
ifUserLogin() {
|
||||||
if (this.userService.getCurrentUserId() === undefined) {
|
if (this.userService.getCurrentUserId() === null) {
|
||||||
this.route.navigateByUrl('/login');
|
this.route.navigateByUrl('/login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import {
|
||||||
updateDoc,
|
updateDoc,
|
||||||
where,
|
where,
|
||||||
} from '@angular/fire/firestore';
|
} from '@angular/fire/firestore';
|
||||||
// import { User } from '../interface/user.interface';
|
|
||||||
import {
|
import {
|
||||||
getAuth,
|
getAuth,
|
||||||
signInWithPopup,
|
signInWithPopup,
|
||||||
|
|
@ -23,7 +22,9 @@ import { Router } from '@angular/router';
|
||||||
import { User } from '../interface/user.interface';
|
import { User } from '../interface/user.interface';
|
||||||
import { UserService } from './user.service';
|
import { UserService } from './user.service';
|
||||||
import { publicChannels } from '../interface/channel.interface';
|
import { publicChannels } from '../interface/channel.interface';
|
||||||
// import { User } from 'firebase/auth';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import CryptoJS from 'crypto-es';
|
||||||
|
import { CryptoJSSecretKey } from './../../environments/config';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
|
|
@ -43,8 +44,13 @@ export class loginService {
|
||||||
passwordIcon: string = './assets/img/login/close-eye.svg';
|
passwordIcon: string = './assets/img/login/close-eye.svg';
|
||||||
private hasAnimationPlayed = false;
|
private hasAnimationPlayed = false;
|
||||||
private introCompleteStatus = false;
|
private introCompleteStatus = false;
|
||||||
|
private secretKey: string = CryptoJSSecretKey.secretKey;
|
||||||
|
|
||||||
constructor(private router: Router, private userService: UserService) {
|
constructor(
|
||||||
|
private router: Router,
|
||||||
|
private userService: UserService,
|
||||||
|
private translate: TranslateService
|
||||||
|
) {
|
||||||
this.ifUserLoggedIn();
|
this.ifUserLoggedIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,7 +60,7 @@ export class loginService {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
ifUserLoggedIn() {
|
ifUserLoggedIn() {
|
||||||
let currentUser = localStorage.getItem('currentUserDABubble');
|
let currentUser = this.userService.getCurrentUserId();
|
||||||
if (currentUser !== null) {
|
if (currentUser !== null) {
|
||||||
this.router.navigate([`/main`]);
|
this.router.navigate([`/main`]);
|
||||||
}
|
}
|
||||||
|
|
@ -78,7 +84,7 @@ export class loginService {
|
||||||
getDocs(querySnapshot)
|
getDocs(querySnapshot)
|
||||||
.then((snapshot) => this.userDocument(snapshot))
|
.then((snapshot) => this.userDocument(snapshot))
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Fehler beim Abrufen des Benutzerdokuments:', error);
|
console.error('Error when retrieving the user document:', error);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|
@ -99,7 +105,7 @@ export class loginService {
|
||||||
this.email = '';
|
this.email = '';
|
||||||
this.password = '';
|
this.password = '';
|
||||||
} else {
|
} else {
|
||||||
console.error('Kein zugehöriges Benutzerdokument gefunden.');
|
console.error('No associated user document found.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,15 +116,19 @@ export class loginService {
|
||||||
switchCase(errorCode: string) {
|
switchCase(errorCode: string) {
|
||||||
switch (errorCode) {
|
switch (errorCode) {
|
||||||
case 'auth/invalid-credential':
|
case 'auth/invalid-credential':
|
||||||
this.errorMessage =
|
this.translate.get('login.errorText3').subscribe((res: string) => {
|
||||||
'*Ungültige Anmeldeinformationen. Bitte überprüfen Sie Ihre Eingaben.';
|
this.errorMessage = res;
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case 'auth/too-many-requests':
|
case 'auth/too-many-requests':
|
||||||
this.errorMessage =
|
this.translate.get('login.errorText4').subscribe((res: string) => {
|
||||||
'*Der Zugriff auf dieses Konto wurde aufgrund zahlreicher fehlgeschlagener Anmeldeversuche vorübergehend deaktiviert.';
|
this.errorMessage = res;
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.errorMessage = '*Bitte Überprüfe deine Eingaben.';
|
this.translate.get('login.errorText5').subscribe((res: string) => {
|
||||||
|
this.errorMessage = res;
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -142,8 +152,9 @@ export class loginService {
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
this.errorMessage =
|
this.translate.get('login.errorText6').subscribe((res: string) => {
|
||||||
'Fehler bei der Gastanmeldung. Bitte versuchen Sie es später erneut.';
|
this.errorMessage = res;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -363,7 +374,7 @@ export class loginService {
|
||||||
talkToUserId: currentUser,
|
talkToUserId: currentUser,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Fehler beim Erstellen des privaten Kanals: ', error);
|
console.error('Error when creating the private channel: ', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -371,8 +382,16 @@ export class loginService {
|
||||||
* Stores the current user's ID in the local storage.
|
* Stores the current user's ID in the local storage.
|
||||||
* @param {string} userId - The ID of the current user to be stored.
|
* @param {string} userId - The ID of the current user to be stored.
|
||||||
*/
|
*/
|
||||||
async getUserIdInLocalStorage(userId: string) {
|
async getUserIdInLocalStorage(userId: string): Promise<void> {
|
||||||
localStorage.setItem('currentUserDABubble', JSON.stringify(userId));
|
const encryptedValue = CryptoJS.AES.encrypt(
|
||||||
|
JSON.stringify(userId),
|
||||||
|
this.secretKey
|
||||||
|
).toString();
|
||||||
|
localStorage.setItem('currentUserDABUBBLE', encryptedValue);
|
||||||
|
localStorage.setItem(
|
||||||
|
'sessionTimeDABUBBLE',
|
||||||
|
new Date().getTime().toString()
|
||||||
|
);
|
||||||
await this.updateUserOnlineStatus(userId);
|
await this.updateUserOnlineStatus(userId);
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ import { User } from '../interface/user.interface';
|
||||||
import { ChannleService } from './channle.service';
|
import { ChannleService } from './channle.service';
|
||||||
import { getAuth, signOut } from 'firebase/auth';
|
import { getAuth, signOut } from 'firebase/auth';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import CryptoJS from 'crypto-es';
|
||||||
|
import { CryptoJSSecretKey } from './../../environments/config';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
|
|
@ -22,6 +24,7 @@ export class UserService implements OnDestroy {
|
||||||
getUserIDs: string[] = [];
|
getUserIDs: string[] = [];
|
||||||
getFiltertUsers: User[] = [];
|
getFiltertUsers: User[] = [];
|
||||||
isUserLogin: boolean = true;
|
isUserLogin: boolean = true;
|
||||||
|
private secretKey: string = CryptoJSSecretKey.secretKey;
|
||||||
|
|
||||||
unsubUser;
|
unsubUser;
|
||||||
|
|
||||||
|
|
@ -34,10 +37,13 @@ export class UserService implements OnDestroy {
|
||||||
* @returns {string|number|undefined} The ID of the current user if found in local storage, otherwise undefined.
|
* @returns {string|number|undefined} The ID of the current user if found in local storage, otherwise undefined.
|
||||||
*/
|
*/
|
||||||
getCurrentUserId() {
|
getCurrentUserId() {
|
||||||
let currentUser = localStorage.getItem('currentUserDABubble');
|
const encryptedValue = localStorage.getItem('currentUserDABUBBLE');
|
||||||
if (currentUser !== null) {
|
if (encryptedValue) {
|
||||||
return JSON.parse(currentUser);
|
const bytes = CryptoJS.AES.decrypt(encryptedValue, this.secretKey);
|
||||||
|
const decryptedValue = bytes.toString(CryptoJS.enc.Utf8);
|
||||||
|
return JSON.parse(decryptedValue);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -162,7 +168,8 @@ export class UserService implements OnDestroy {
|
||||||
* Deletes the user ID from local storage.
|
* Deletes the user ID from local storage.
|
||||||
*/
|
*/
|
||||||
deleteUserIdInLocalStorage() {
|
deleteUserIdInLocalStorage() {
|
||||||
localStorage.removeItem('currentUserDABubble');
|
localStorage.removeItem('currentUserDABUBBLE');
|
||||||
|
localStorage.removeItem('sessionTimeDABUBBLE');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,11 @@
|
||||||
"topText": "Neu bei DABubble?",
|
"topText": "Neu bei DABubble?",
|
||||||
"topText2": "Konto erstellen",
|
"topText2": "Konto erstellen",
|
||||||
"errorText": "*Email ist erforderlich.",
|
"errorText": "*Email ist erforderlich.",
|
||||||
"errorText2": "*Passwort ist erforderlich."
|
"errorText2": "*Passwort ist erforderlich.",
|
||||||
|
"errorText3": "*Ungültige Anmeldeinformationen.",
|
||||||
|
"errorText4": "*Zuviele fehlgeschlagener Anmeldeversuche.",
|
||||||
|
"errorText5": "*Bitte Überprüfe deine Eingaben.",
|
||||||
|
"errorText6": "*Bitte versuchen Sie es später erneut."
|
||||||
},
|
},
|
||||||
|
|
||||||
"createAccount": {
|
"createAccount": {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,11 @@
|
||||||
"topText": "New to DABubble?",
|
"topText": "New to DABubble?",
|
||||||
"topText2": "Create account",
|
"topText2": "Create account",
|
||||||
"errorText": "*Email is required.",
|
"errorText": "*Email is required.",
|
||||||
"errorText2": "*Password is required."
|
"errorText2": "*Password is required.",
|
||||||
|
"errorText3": "*Invalid login credentials.",
|
||||||
|
"errorText4": "*Too many failed login attempts.",
|
||||||
|
"errorText5": "*Please check your entries.",
|
||||||
|
"errorText6": "*Please try again later."
|
||||||
},
|
},
|
||||||
|
|
||||||
"createAccount": {
|
"createAccount": {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue