Skip to content
Snippets Groups Projects
Verified Commit cd7ff921 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #8836 add cookie for auth info

parent 42570bee
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,7 @@
"interactjs": "^1.4.0-alpha.16",
"jquery": "^3.3.1",
"ng2-pdf-viewer": "^5.1.3",
"ngx-cookie-service": "^2.0.0",
"ngx-scroll-event": "^1.0.8",
"pdfjs-dist": "2.0.550",
"rxjs": "^6.0.0",
......
......@@ -18,6 +18,7 @@ use Respect\Validation\Validator;
use Slim\Http\Request;
use Slim\Http\Response;
use SrcCore\models\AuthenticationModel;
use User\models\UserModel;
class AuthenticationController
{
......@@ -55,6 +56,8 @@ class AuthenticationController
AuthenticationModel::setCookieAuth(['login' => $data['login']]);
return $response->withJson(['success' => 'success']);
$userInfo = UserModel::getByLogin(['login' => $data['login'], 'select' => ['id', 'firstname', 'lastname', 'mail']]);
return $response->withJson(['user' => $userInfo]);
}
}
import { Component, ViewEncapsulation } from '@angular/core';
import { MatIconRegistry } from '@angular/material';
import { DomSanitizer } from '@angular/platform-browser';
import { CookieService } from 'ngx-cookie-service';
import { empty } from 'rxjs';
import { SignaturesContentService } from './service/signatures.service';
@Component({
selector: 'app-root',
......@@ -11,5 +12,12 @@ import { DomSanitizer } from '@angular/platform-browser';
export class AppComponent {
constructor() { }
constructor(public signaturesService: SignaturesContentService, private cookieService: CookieService) {
if (this.cookieService.check( 'maarchParafUserId')) {
this.signaturesService.userLogged.id = this.cookieService.get( 'maarchParafUserId');
this.signaturesService.userLogged.firstname = this.cookieService.get( 'maarchParafUserFirstname');
this.signaturesService.userLogged.lastname = this.cookieService.get( 'maarchParafUserLastname');
this.signaturesService.userLogged.mail = this.cookieService.get( 'maarchParafUserMail');
}
}
}
......@@ -8,6 +8,7 @@ import { HammerGestureConfig, HAMMER_GESTURE_CONFIG } from '@angular/platform-br
import { PdfViewerModule } from 'ng2-pdf-viewer';
import { ScrollEventModule } from 'ngx-scroll-event';
import { AngularDraggableModule } from 'angular2-draggable';
import { CookieService } from 'ngx-cookie-service';
import { AppMaterialModule } from './app-material.module';
......@@ -75,7 +76,8 @@ import { SignaturesContentService } from './service/signatures.service';
{
provide: HAMMER_GESTURE_CONFIG,
useClass: HammerGestureConfig
}],
},
CookieService],
exports: [
RouterModule
],
......
import { Component, AfterViewInit } from '@angular/core';
import { Component, AfterViewInit, OnInit } from '@angular/core';
import { trigger, transition, style, animate } from '@angular/animations';
import { DomSanitizer } from '@angular/platform-browser';
import { MatIconRegistry, MatSnackBar } from '@angular/material';
import { HttpClient } from '@angular/common/http';
import { Router } from '@angular/router';
import { SignaturesContentService } from '../service/signatures.service';
import { CookieService } from 'ngx-cookie-service';
@Component({
templateUrl: 'login.component.html',
styleUrls: ['login.component.styl'],
animations: [
trigger(
'myAnimation',
[
transition(
':enter', [
style({transform: 'translateX(100%)', opacity: 0}),
animate('500ms', style({transform: 'translateX(0)', 'opacity': 1}))
]
),
transition(
':leave', [
style({transform: 'translateX(0)', 'opacity': 1}),
animate('500ms', style({transform: 'translateX(100%)', 'opacity': 0})),
]
)]
'myAnimation',
[
transition(
':enter', [
style({ transform: 'translateX(100%)', opacity: 0 }),
animate('500ms', style({ transform: 'translateX(0)', 'opacity': 1 }))
]
),
transition(
':leave', [
style({ transform: 'translateX(0)', 'opacity': 1 }),
animate('500ms', style({ transform: 'translateX(100%)', 'opacity': 0 })),
]
)]
)
],
],
})
export class LoginComponent implements AfterViewInit {
export class LoginComponent implements OnInit, AfterViewInit {
loadingForm = true;
newLogin = {
id : '',
password : ''
id: '',
password: ''
};
labelButton = 'Se connecter';
loadingConnexion = false;
constructor(public http: HttpClient, private router: Router, iconReg: MatIconRegistry, sanitizer: DomSanitizer, public snackBar: MatSnackBar) {
constructor(public http: HttpClient, private cookieService: CookieService, private router: Router, iconReg: MatIconRegistry, sanitizer: DomSanitizer, public snackBar: MatSnackBar, public signaturesService: SignaturesContentService) {
iconReg.addSvgIcon('maarchLogo', sanitizer.bypassSecurityTrustResourceUrl('../src/assets/logo_white.svg'));
}
ngOnInit(): void {
this.signaturesService.userLogged = {};
this.cookieService.deleteAll();
}
ngAfterViewInit(): void {
setTimeout(() => {
$('.maarchLogo').css({'transform': 'translateY(-200px)'});
$('.maarchLogo').css({ 'transform': 'translateY(-200px)' });
}, 200);
setTimeout(() => {
this.loadingForm = false;
......@@ -55,19 +62,24 @@ export class LoginComponent implements AfterViewInit {
this.labelButton = 'Connexion ...';
this.loadingConnexion = true;
this.http.post('../rest/log', {'login': this.newLogin.id, 'password': this.newLogin.password})
.subscribe(() => {
this.router.navigate(['/document/']);
}, (err: any) => {
this.labelButton = 'Se connecter';
this.loadingConnexion = false;
this.snackBar.open(err.error.errors, null,
{
duration: 3000,
panelClass: 'center-snackbar',
verticalPosition: 'top'
}
);
});
this.http.post('../rest/log', { 'login': this.newLogin.id, 'password': this.newLogin.password })
.subscribe((data: any) => {
this.signaturesService.userLogged = data.user;
this.cookieService.set( 'maarchParafUserId', data.user.id );
this.cookieService.set( 'maarchParafUserFirstname', data.user.firstname );
this.cookieService.set( 'maarchParafUserLastname', data.user.lastname );
this.cookieService.set( 'maarchParafUserMail', data.user.mail );
this.router.navigate(['/document/']);
}, (err: any) => {
this.labelButton = 'Se connecter';
this.loadingConnexion = false;
this.snackBar.open(err.error.errors, null,
{
duration: 3000,
panelClass: 'center-snackbar',
verticalPosition: 'top'
}
);
});
}
}
......@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
@Injectable()
export class SignaturesContentService {
userLogged: any = {};
mainDocumentId: Number = 0;
signaturesContent: any[] = [];
notesContent: any[] = [];
......
<nav class="sidebar">
<header class="sidebar-header">
<section class="sidebar-header-icon notification">
<i class="fa fa-folder-open fa-2x"></i>
<div class="main-header">
<header class="profile-header">
<button class="logout-button" mat-icon-button routerLink="/login">
<mat-icon fontSet="fas" fontIcon="fa-sign-out-alt"></mat-icon>
</button>
<div class="user">
{{signaturesService.userLogged.firstname}} {{signaturesService.userLogged.lastname}}
</div>
<div class="avatar">
</div>
</header>
<header class="sidebar-header">
<section class="sidebar-header-icon notification">
<i class="fa fa-folder-open fa-2x"></i>
</section>
<section>
<div class="sidebar-header-title">{{signaturesService.documentsListCount}} dossiers à traiter</div>
</section>
</header>
<section class="sidebar-btn">
<button class="btn btn-xs blue">Annotation</button>
<button class="btn btn-xs blue">Paraphe</button>
</section>
<section>
<div class="sidebar-header-title">{{signaturesService.documentsListCount}} dossiers à traiter</div>
<div class="sidebar-header-subtitle">dans la banette</div>
</section>
</header>
<section class="sidebar-btn">
<button class="btn btn-xs blue">Annotation</button>
<button class="btn btn-xs blue">Paraphe</button>
</section>
</div>
<ul #listContent class="nav" detect-scroll (onScroll)="handleScroll($event)" [bottomOffset]="1" [topOffset]="1">
<div *ngIf="loadingList" class="loadList">
<mat-spinner></mat-spinner>
<mat-spinner></mat-spinner>
</div>
<ng-container *ngFor="let document of signaturesService.documentsList;let i=index">
<li class="nav-item active" matRipple (click)="gotTo(document.id, i)">
<div class="nav-item-left">
<i class="fas fa-mail-bulk"></i>
</div>
<div class="nav-item-middle">
<div class="nav-item-title">{{document.reference}}</div>
<div class="">{{document.subject}}</div>
</div>
<div class="nav-item-right">
<i class="fas fa-arrow-right"></i>
</div>
</li>
<li class="nav-item active" matRipple (click)="gotTo(document.id, i)">
<div class="nav-item-left">
<i class="fas fa-mail-bulk"></i>
</div>
<div class="nav-item-middle">
<div class="nav-item-title">{{document.reference}}</div>
<div class="">{{document.subject}}</div>
</div>
<div class="nav-item-right">
<i class="fas fa-arrow-right"></i>
</div>
</li>
</ng-container>
</ul>
</nav>
</nav>
\ No newline at end of file
.main-header
height 25%
overflow auto
.sidebar
position relative
height 100%
......@@ -5,12 +9,13 @@
&-header
background #F1F4F4
height 10%
height 50px
display flex
align-items center
justify-content center
font-size 14px
font-weight 600
padding-top 10px
&-icon
margin-right 15px
position relative
......@@ -27,12 +32,12 @@
&-subtitle
color #9B9B9B
&-btn
height 10%
height 50px
display flex
align-items center
justify-content space-around
.nav
height 80%
height 75%
overflow-y scroll
margin-top 0px
overflow-x hidden
......@@ -82,4 +87,32 @@
z-index 1
display flex
align-items baseline
justify-content center
\ No newline at end of file
justify-content center
.profile-header
background #135F7F
height 95px
display flex
justify-content center
position relative
.avatar
position absolute
background url(https://image.flaticon.com/icons/svg/147/147144.svg) white
width 65px
height 65px
border-radius 40px
bottom -20px
border solid 3px white
.user
color white
padding-top 10px
font-weight bold
font-size 20px
.logout-button
font-size 30px
color white
position absolute
right 10px
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment