prompt page pass

This commit is contained in:
Tykayn 2021-06-10 12:20:28 +02:00 committed by tykayn
parent 534ef03f6a
commit 06dbef8040
9 changed files with 108 additions and 10 deletions

View File

@ -50,7 +50,7 @@
"bulma": "^0.9.0", "bulma": "^0.9.0",
"bulma-switch": "^2.0.0", "bulma-switch": "^2.0.0",
"chart.js": "^2.9.3", "chart.js": "^2.9.3",
"crypto": "^1.0.1", "crypto-js": "^4.0.0",
"fork-awesome": "^1.1.7", "fork-awesome": "^1.1.7",
"ng-keyboard-shortcuts": "^10.1.17", "ng-keyboard-shortcuts": "^10.1.17",
"ng2-charts": "^2.3.0", "ng2-charts": "^2.3.0",
@ -78,6 +78,7 @@
"@compodoc/compodoc": "^1.1.11", "@compodoc/compodoc": "^1.1.11",
"@types/jest": "^26.0.0", "@types/jest": "^26.0.0",
"@types/node": "^14.0.1", "@types/node": "^14.0.1",
"@types/crypto-js": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^3.0.0", "@typescript-eslint/eslint-plugin": "^3.0.0",
"@typescript-eslint/parser": "^3.0.0", "@typescript-eslint/parser": "^3.0.0",
"babel-jest": "^26.0.0", "babel-jest": "^26.0.0",

View File

@ -171,6 +171,8 @@ export class ApiService {
} catch (error) { } catch (error) {
if (error.response?.status === 404) { if (error.response?.status === 404) {
return undefined; return undefined;
} else if (error.response?.status === 403) {
return error;
} else { } else {
ApiService.handleError(error); ApiService.handleError(error);
} }

View File

@ -3,16 +3,17 @@ import { RouterModule, Routes } from '@angular/router';
import { ConsultationComponent } from './consultation.component'; import { ConsultationComponent } from './consultation.component';
import { WipTodoComponent } from '../../shared/components/ui/wip-todo/wip-todo.component'; import { WipTodoComponent } from '../../shared/components/ui/wip-todo/wip-todo.component';
import { PasswordPromptComponent } from './password/password-prompt/password-prompt.component';
const routes: Routes = [ const routes: Routes = [
{ path: 'secure/:pass_hash', component: ConsultationComponent }, { path: 'secure/:pass_hash', component: ConsultationComponent },
{ path: 'prompt', component: PasswordPromptComponent },
{ path: 'simple', component: WipTodoComponent },
{ path: 'table', component: WipTodoComponent },
{ {
path: '', path: '',
component: ConsultationComponent, component: ConsultationComponent,
children: [ children: [],
{ path: 'simple', component: WipTodoComponent },
{ path: 'table', component: WipTodoComponent },
],
}, },
]; ];
@NgModule({ @NgModule({

View File

@ -8,6 +8,7 @@ import { ConsultationComponent } from './consultation.component';
import { PollResultsCompactComponent } from './poll-results-compact/poll-results-compact.component'; import { PollResultsCompactComponent } from './poll-results-compact/poll-results-compact.component';
import { PollResultsDetailedComponent } from './poll-results-detailed/poll-results-detailed.component'; import { PollResultsDetailedComponent } from './poll-results-detailed/poll-results-detailed.component';
import { ChoiceButtonComponent } from '../../shared/components/choice-item/choice-button.component'; import { ChoiceButtonComponent } from '../../shared/components/choice-item/choice-button.component';
import { PasswordPromptComponent } from './password/password-prompt/password-prompt.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -15,6 +16,7 @@ import { ChoiceButtonComponent } from '../../shared/components/choice-item/choic
PollResultsCompactComponent, PollResultsCompactComponent,
PollResultsDetailedComponent, PollResultsDetailedComponent,
ChoiceButtonComponent, ChoiceButtonComponent,
PasswordPromptComponent,
], ],
imports: [CommonModule, ConsultationRoutingModule, SharedModule, TranslateModule.forChild({ extend: true })], imports: [CommonModule, ConsultationRoutingModule, SharedModule, TranslateModule.forChild({ extend: true })],
}) })

View File

@ -0,0 +1,29 @@
<div class="padded">
<h1>
<i class="fa fa-key"></i>
Sondage protégé
</h1>
<p>Pour accéder au sondage {{ custom_url }} il vous faut saisir la phrase de passe.</p>
<input type="text" [(ngModel)]="password" *ngIf="display_pass" />
<input type="password" [(ngModel)]="password" *ngIf="!display_pass" />
<br />
<button (click)="display_pass = !display_pass">voir</button>
<br />
Méthode de chiffrement 1:
<select name="ciphering_method" id="ciphering_method">
<option value="MD5">MD5</option>
</select>
Méthode de chiffrement 2:
<select name="ciphering_method_2" id="ciphering_method_2">
<option value="MD5">MD5</option>
</select>
steak haché:
{{ cipherPass() }}
<br />
<button class="is-primary button is-large" (click)="redirectToConsultationPage()">
Allons-y
</button>
</div>

View File

@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PasswordPromptComponent } from './password-prompt.component';
describe('PasswordPromptComponent', () => {
let component: PasswordPromptComponent;
let fixture: ComponentFixture<PasswordPromptComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [PasswordPromptComponent],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PasswordPromptComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,34 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
import { MD5, enc } from 'crypto-js';
@Component({
selector: 'app-password-prompt',
templateUrl: './password-prompt.component.html',
styleUrls: ['./password-prompt.component.scss'],
})
export class PasswordPromptComponent implements OnInit {
password = 'le pass woute woute';
method = 'md5';
display_pass = true;
custom_url = '';
password_ciphered: string;
constructor(private router: Router, private _Activatedroute: ActivatedRoute) {}
ngOnInit(): void {
this._Activatedroute.paramMap.subscribe((params: ParamMap) => {
this.custom_url = params.get('custom_url');
});
}
cipherPass() {
this.password_ciphered = MD5(this.password).toString(enc.Hex);
this.password_ciphered = MD5(this.password_ciphered).toString(enc.Hex);
return this.password_ciphered;
}
redirectToConsultationPage() {
this.router.navigate(['/poll/' + this.custom_url + '/consultation/secure/' + this.password_ciphered]);
}
}

View File

@ -1678,6 +1678,11 @@
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ== integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==
"@types/crypto-js@^4.0.0":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@types/crypto-js/-/crypto-js-4.0.1.tgz#3a4bd24518b0e6c5940da4e2659eeb2ef0806963"
integrity sha512-6+OPzqhKX/cx5xh+yO8Cqg3u3alrkhoxhE5ZOdSEv0DOzJ13lwJ6laqGU0Kv6+XDMFmlnGId04LtY22PsFLQUw==
"@types/eslint-visitor-keys@^1.0.0": "@types/eslint-visitor-keys@^1.0.0":
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
@ -3745,16 +3750,16 @@ crypto-js@^3.1.9-1:
resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.3.0.tgz#846dd1cce2f68aacfa156c8578f926a609b7976b" resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.3.0.tgz#846dd1cce2f68aacfa156c8578f926a609b7976b"
integrity sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q== integrity sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q==
crypto-js@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.0.0.tgz#2904ab2677a9d042856a2ea2ef80de92e4a36dcc"
integrity sha512-bzHZN8Pn+gS7DQA6n+iUmBfl0hO5DJq++QP3U6uTucDtk/0iGpXd/Gg7CGR0p8tJhofJyaKoWBuJI4eAO00BBg==
crypto-random-string@^2.0.0: crypto-random-string@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-2.0.0.tgz#ef2a7a966ec11083388369baa02ebead229b30d5" resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-2.0.0.tgz#ef2a7a966ec11083388369baa02ebead229b30d5"
integrity sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA== integrity sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==
crypto@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/crypto/-/crypto-1.0.1.tgz#2af1b7cad8175d24c8a1b0778255794a21803037"
integrity sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==
css-color-names@0.0.4, css-color-names@^0.0.4: css-color-names@0.0.4, css-color-names@^0.0.4:
version "0.0.4" version "0.0.4"
resolved "https://registry.yarnpkg.com/css-color-names/-/css-color-names-0.0.4.tgz#808adc2e79cf84738069b646cb20ec27beb629e0" resolved "https://registry.yarnpkg.com/css-color-names/-/css-color-names-0.0.4.tgz#808adc2e79cf84738069b646cb20ec27beb629e0"