Moved
This commit is contained in:
parent
bc62ef4f0d
commit
a18333c2c3
101 changed files with 54 additions and 59 deletions
|
|
@ -0,0 +1,16 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CheckEmailService } from './check-email.service';
|
||||
|
||||
describe('CheckEmailService', () => {
|
||||
let service: CheckEmailService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(CheckEmailService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class CheckEmailService
|
||||
{
|
||||
|
||||
isValidEmail(email: string): boolean
|
||||
{
|
||||
let re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
return re.test(email);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { FictitiousDatasService } from './fictitious-datas.service';
|
||||
|
||||
describe('FictitiousDatasService', () => {
|
||||
let service: FictitiousDatasService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(FictitiousDatasService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class FictitiousDatasService
|
||||
{
|
||||
|
||||
getUser()
|
||||
{
|
||||
const id = (Math.floor(Math.random()*100000)).toString()
|
||||
return {
|
||||
id: id,
|
||||
nickname: "Riri"+id,
|
||||
email: "riri"+id+"@gmail.com",
|
||||
hash_pass: "blablabla",
|
||||
is_admin: false,
|
||||
}
|
||||
}
|
||||
|
||||
getAdmin()
|
||||
{
|
||||
const id = (Math.floor(Math.random()*100000)).toString()
|
||||
return {
|
||||
id: id,
|
||||
nickname: "Fifi"+id,
|
||||
email: "fifi"+id+"@gmail.com",
|
||||
hash_pass: "blablabla",
|
||||
is_admin: true,
|
||||
}
|
||||
}
|
||||
|
||||
getTabPerson(n: number)
|
||||
{
|
||||
let tab = [];
|
||||
|
||||
for(let i=0 ; i<n ; i++)
|
||||
{
|
||||
if(Math.random() < 0.5) tab.push(this.getUser());
|
||||
else tab.push(this.getAdmin());
|
||||
}
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { HashageService } from './hashage.service';
|
||||
|
||||
describe('HashageService', () => {
|
||||
let service: HashageService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(HashageService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
19
frontend/src/app/common/services/hashage/hashage.service.ts
Normal file
19
frontend/src/app/common/services/hashage/hashage.service.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class HashageService
|
||||
{
|
||||
// Fonction de hashage (faible)
|
||||
run(input: string): string
|
||||
{
|
||||
let hash = 0;
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
let ch = input.charCodeAt(i);
|
||||
hash = ((hash << 5) - hash) + ch;
|
||||
hash = hash & hash;
|
||||
}
|
||||
return hash.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { MessageService } from './message.service';
|
||||
|
||||
describe('MessageService', () => {
|
||||
let service: MessageService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(MessageService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
38
frontend/src/app/common/services/message/message.service.ts
Normal file
38
frontend/src/app/common/services/message/message.service.ts
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import {HttpClient, HttpParams} from "@angular/common/http";
|
||||
import {Observable} from "rxjs";
|
||||
import {environment} from "../../../../environments/environment";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class MessageService
|
||||
{
|
||||
|
||||
constructor( private http: HttpClient ) { }
|
||||
|
||||
post(url: string, data: any): Observable<any>
|
||||
{
|
||||
const urlComplete = environment.debutUrl + url ;
|
||||
return this.http.post<any>(urlComplete, data, {withCredentials: true});
|
||||
}
|
||||
|
||||
get(url: string, params:HttpParams = new HttpParams()): Observable<any>
|
||||
{
|
||||
const urlComplete = environment.debutUrl + url ;
|
||||
return this.http.get<any>(urlComplete,{ withCredentials: true, params: params });
|
||||
}
|
||||
|
||||
put(url: string, data: any): Observable<any>
|
||||
{
|
||||
const urlComplete = environment.debutUrl + url ;
|
||||
return this.http.put<any>(urlComplete, data, {withCredentials: true});
|
||||
}
|
||||
|
||||
delete(url: string, params:HttpParams = new HttpParams()): Observable<any>
|
||||
{
|
||||
const urlComplete = environment.debutUrl + url ;
|
||||
return this.http.delete<any>(urlComplete,{withCredentials: true});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ProfilService } from './profil.service';
|
||||
|
||||
describe('ProfilService', () => {
|
||||
let service: ProfilService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(ProfilService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
42
frontend/src/app/common/services/profil/profil.service.ts
Normal file
42
frontend/src/app/common/services/profil/profil.service.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ProfilService
|
||||
{
|
||||
|
||||
constructor()
|
||||
{
|
||||
if(localStorage.getItem('id') === null) this.setId(-1);
|
||||
if(localStorage.getItem('isAdmin') === null) this.setIsAdmin(false);
|
||||
}
|
||||
|
||||
getId(): number
|
||||
{
|
||||
let idString = localStorage.getItem('id');
|
||||
if(idString === null) return -1;
|
||||
else return parseInt(idString);
|
||||
}
|
||||
|
||||
setId(id: number): void
|
||||
{
|
||||
localStorage.setItem('id', id.toString());
|
||||
}
|
||||
|
||||
isAdmin(): boolean
|
||||
{
|
||||
let isAdminString = localStorage.getItem('isAdmin');
|
||||
if(isAdminString === "T") return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
setIsAdmin(isAdmin: boolean): void
|
||||
{
|
||||
let isAdminString = "" ;
|
||||
if(isAdmin) isAdminString = "T";
|
||||
else isAdminString = "F";
|
||||
localStorage.setItem('isAdmin', isAdminString);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue