Skip to content

Commit

Permalink
fix(backend): fix role for doc download
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Oct 30, 2024
1 parent a21e9cc commit be58aba
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion packages/backend/src/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { StructuresAuthController } from "./structures-auth.controller";
JwtModule.register({
secret: domifaConfig().security.jwtSecret,
signOptions: {
expiresIn: "24h",
expiresIn: "12h",
},
})
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class UsagerDocAccessGuard implements CanActivate {
const user = request?.user as UserStructureAuthenticated;

if (
user?.role === "simple" ||
user?.role === "facteur" ||
!isUUID(request.params.docUuid) ||
!isNumber(user?.structureId)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("StructuresAuthService", () => {
JwtModule.register({
secretOrPrivateKey: "secretKey",
signOptions: {
expiresIn: 3600,
expiresIn: "12h",
},
}),
UsersModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("AdminsAuthService", () => {
JwtModule.register({
secretOrPrivateKey: "secretKey",
signOptions: {
expiresIn: 3600,
expiresIn: "12h",
},
}),
UsersModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class PortailUsagersProfileController {
});

try {
return this.fileManagerService.dowloadEncryptedFile(
return await this.fileManagerService.dowloadEncryptedFile(
res,
currentUser.structure.uuid,
currentUser.usager.uuid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("UsagersAuthService", () => {
JwtModule.register({
secretOrPrivateKey: "secretKey",
signOptions: {
expiresIn: 3600,
expiresIn: "12h",
},
}),
UsersModule,
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/app/interceptors/jwt.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class JwtInterceptor implements HttpInterceptor {
): Observable<HttpEvent<any>> {
const currentUser = this.authService.currentUserValue;

if (currentUser && currentUser.access_token) {
if (currentUser?.access_token) {
request = request.clone({
setHeaders: {
Authorization: `Bearer ${currentUser.access_token}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
<fa-icon
[icon]="['fas', 'circle-notch']"
aria-hidden="true"
[fixedWidth]="true"
[spin]="true"
></fa-icon>
Patientez...
{{ loadingText }}
</span>
<span *ngIf="!loading">
<fa-icon
Expand All @@ -26,20 +27,4 @@
></fa-icon>
{{ content }}
</span>

<span
*ngIf="loading"
class="position-absolute top-50 start-50 translate-middle d-inline-flex align-items-center"
role="status"
[attr.aria-label]="loadingAriaLabel"
>
<fa-icon
[icon]="['fas', 'circle-notch']"
[spin]="true"
[fixedWidth]="true"
class="me-1"
aria-hidden="true"
></fa-icon>
{{ loadingText }}
</span>
</button>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class ButtonComponent {
@Input() icon?: IconName;
@Input() prefix: IconPrefix = "fas";
@Input() loadingText = "Patientez...";
@Input() loadingAriaLabel = "Chargement en cours";
@Input() content = "";
@Input() ariaLabel = "";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ export class UploadComponent implements OnInit, OnDestroy {
file: ["", [Validators.required]],
label: [
"",
[Validators.required, NoWhiteSpaceValidator, Validators.minLength(2)],
[
Validators.required,
NoWhiteSpaceValidator,
Validators.minLength(2),
Validators.maxLength(100),
],
],
});
}
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/assets/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ul {
caption {
color: black !important;
}

.content {
background-color: #f2f2f2;
min-height: calc(90vh - 78px);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import { ComponentFixture, TestBed } from "@angular/core/testing";

import { SectionDocsComponent } from "./section-docs.component";
import { DEFAULT_USAGER } from "../../../../../../../_common";
import { HttpClientTestingModule } from "@angular/common/http/testing";
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from "@angular/core";
import { SharedModule } from "../../../../../shared/shared.module";

describe("SectionDocsComponent", () => {
let component: SectionDocsComponent;
let fixture: ComponentFixture<SectionDocsComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [SectionDocsComponent],
declarations: [SectionDocsComponent],
imports: [SharedModule, HttpClientTestingModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
}).compileComponents();

fixture = TestBed.createComponent(SectionDocsComponent);
component = fixture.componentInstance;
component.usager = DEFAULT_USAGER;
fixture.detectChanges();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { TestBed } from "@angular/core/testing";

import { UsagerDocService } from "./usager-doc.service";
import { HttpClientTestingModule } from "@angular/common/http/testing";

describe("UsagerDocService", () => {
let service: UsagerDocService;

beforeEach(() => {
TestBed.configureTestingModule({});
TestBed.configureTestingModule({ imports: [HttpClientTestingModule] });
service = TestBed.inject(UsagerDocService);
});

Expand Down

0 comments on commit be58aba

Please sign in to comment.