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",
|
||||
"@ngx-translate/core": "^15.0.0",
|
||||
"@ngx-translate/http-loader": "^8.0.0",
|
||||
"crypto-es": "^2.1.0",
|
||||
"ng2-pdf-viewer": "^10.0.0",
|
||||
"ngx-extended-pdf-viewer": "^19.6.6",
|
||||
"rxjs": "~7.8.0",
|
||||
|
|
@ -6106,6 +6107,11 @@
|
|||
"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": {
|
||||
"version": "6.10.0",
|
||||
"resolved": "https://registry.npmjs.org/css-loader/-/css-loader-6.10.0.tgz",
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
"@ctrl/ngx-emoji-mart": "^9.2.0",
|
||||
"@ngx-translate/core": "^15.0.0",
|
||||
"@ngx-translate/http-loader": "^8.0.0",
|
||||
"crypto-es": "^2.1.0",
|
||||
"ng2-pdf-viewer": "^10.0.0",
|
||||
"ngx-extended-pdf-viewer": "^19.6.6",
|
||||
"rxjs": "~7.8.0",
|
||||
|
|
|
|||
|
|
@ -12,6 +12,4 @@ import { ToggleBooleanService } from './service/toggle-boolean.service';
|
|||
})
|
||||
export class AppComponent {
|
||||
title = 'dabubble';
|
||||
|
||||
constructor(public toggleAllBooleans:ToggleBooleanService){}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ export class MainComponent {
|
|||
* Checks if the user is logged in.
|
||||
*/
|
||||
ifUserLogin() {
|
||||
if (this.userService.getCurrentUserId() === undefined) {
|
||||
if (this.userService.getCurrentUserId() === null) {
|
||||
this.route.navigateByUrl('/login');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import {
|
|||
updateDoc,
|
||||
where,
|
||||
} from '@angular/fire/firestore';
|
||||
// import { User } from '../interface/user.interface';
|
||||
import {
|
||||
getAuth,
|
||||
signInWithPopup,
|
||||
|
|
@ -23,7 +22,9 @@ import { Router } from '@angular/router';
|
|||
import { User } from '../interface/user.interface';
|
||||
import { UserService } from './user.service';
|
||||
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({
|
||||
providedIn: 'root',
|
||||
|
|
@ -43,8 +44,13 @@ export class loginService {
|
|||
passwordIcon: string = './assets/img/login/close-eye.svg';
|
||||
private hasAnimationPlayed = 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();
|
||||
}
|
||||
|
||||
|
|
@ -54,7 +60,7 @@ export class loginService {
|
|||
* @returns {void}
|
||||
*/
|
||||
ifUserLoggedIn() {
|
||||
let currentUser = localStorage.getItem('currentUserDABubble');
|
||||
let currentUser = this.userService.getCurrentUserId();
|
||||
if (currentUser !== null) {
|
||||
this.router.navigate([`/main`]);
|
||||
}
|
||||
|
|
@ -78,7 +84,7 @@ export class loginService {
|
|||
getDocs(querySnapshot)
|
||||
.then((snapshot) => this.userDocument(snapshot))
|
||||
.catch((error) => {
|
||||
console.error('Fehler beim Abrufen des Benutzerdokuments:', error);
|
||||
console.error('Error when retrieving the user document:', error);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
|
|
@ -99,7 +105,7 @@ export class loginService {
|
|||
this.email = '';
|
||||
this.password = '';
|
||||
} 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) {
|
||||
switch (errorCode) {
|
||||
case 'auth/invalid-credential':
|
||||
this.errorMessage =
|
||||
'*Ungültige Anmeldeinformationen. Bitte überprüfen Sie Ihre Eingaben.';
|
||||
this.translate.get('login.errorText3').subscribe((res: string) => {
|
||||
this.errorMessage = res;
|
||||
});
|
||||
break;
|
||||
case 'auth/too-many-requests':
|
||||
this.errorMessage =
|
||||
'*Der Zugriff auf dieses Konto wurde aufgrund zahlreicher fehlgeschlagener Anmeldeversuche vorübergehend deaktiviert.';
|
||||
this.translate.get('login.errorText4').subscribe((res: string) => {
|
||||
this.errorMessage = res;
|
||||
});
|
||||
break;
|
||||
default:
|
||||
this.errorMessage = '*Bitte Überprüfe deine Eingaben.';
|
||||
this.translate.get('login.errorText5').subscribe((res: string) => {
|
||||
this.errorMessage = res;
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -142,8 +152,9 @@ export class loginService {
|
|||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
this.errorMessage =
|
||||
'Fehler bei der Gastanmeldung. Bitte versuchen Sie es später erneut.';
|
||||
this.translate.get('login.errorText6').subscribe((res: string) => {
|
||||
this.errorMessage = res;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -363,7 +374,7 @@ export class loginService {
|
|||
talkToUserId: currentUser,
|
||||
});
|
||||
} 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.
|
||||
* @param {string} userId - The ID of the current user to be stored.
|
||||
*/
|
||||
async getUserIdInLocalStorage(userId: string) {
|
||||
localStorage.setItem('currentUserDABubble', JSON.stringify(userId));
|
||||
async getUserIdInLocalStorage(userId: string): Promise<void> {
|
||||
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);
|
||||
window.location.reload();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import { User } from '../interface/user.interface';
|
|||
import { ChannleService } from './channle.service';
|
||||
import { getAuth, signOut } from 'firebase/auth';
|
||||
import { Router } from '@angular/router';
|
||||
import CryptoJS from 'crypto-es';
|
||||
import { CryptoJSSecretKey } from './../../environments/config';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
|
|
@ -22,6 +24,7 @@ export class UserService implements OnDestroy {
|
|||
getUserIDs: string[] = [];
|
||||
getFiltertUsers: User[] = [];
|
||||
isUserLogin: boolean = true;
|
||||
private secretKey: string = CryptoJSSecretKey.secretKey;
|
||||
|
||||
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.
|
||||
*/
|
||||
getCurrentUserId() {
|
||||
let currentUser = localStorage.getItem('currentUserDABubble');
|
||||
if (currentUser !== null) {
|
||||
return JSON.parse(currentUser);
|
||||
const encryptedValue = localStorage.getItem('currentUserDABUBBLE');
|
||||
if (encryptedValue) {
|
||||
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.
|
||||
*/
|
||||
deleteUserIdInLocalStorage() {
|
||||
localStorage.removeItem('currentUserDABubble');
|
||||
localStorage.removeItem('currentUserDABUBBLE');
|
||||
localStorage.removeItem('sessionTimeDABUBBLE');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -12,7 +12,11 @@
|
|||
"topText": "Neu bei DABubble?",
|
||||
"topText2": "Konto erstellen",
|
||||
"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": {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,11 @@
|
|||
"topText": "New to DABubble?",
|
||||
"topText2": "Create account",
|
||||
"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": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue