Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expert form contact #381

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2ebecf0
Refactor expertise form
nutfdt Jun 23, 2024
18448f2
Merge branch 'develop' into expert-contact-newbackend
nutfdt Jun 23, 2024
86247b0
Merge branch 'develop' into expert-contact-newbackend
nutfdt Jul 15, 2024
366e132
fix: :bug: fix popup uzi video
nutfdt Jul 15, 2024
9af6aa9
ci: :green_heart: fix ci build by removing references to deleted files
thomashbrnrd Jul 12, 2024
fdfd446
fix: :bug: fix disclaimer display on dummy weapons
nutfdt Jul 16, 2024
d246280
style: :speech_balloon: update text for sending email to ircgn
nutfdt Jul 17, 2024
7d76bb5
fix: :bug: fix tutorial log when user is not able to perform a step
thomashbrnrd Jul 17, 2024
b358002
fix: :bug: feedback not working on resultpage
thomashbrnrd Jul 17, 2024
da762b3
ci: :fire: remove ci related to new tag which is not used anymore
thomashbrnrd Jul 17, 2024
8e7e7b3
build: :green_heart: add CI_COMMIT_TAG to docker image names in gitla…
thomashbrnrd Jul 17, 2024
02ab08c
Show contact only to authenticated users
thomashbrnrd Jul 11, 2024
038d022
fix: :bug: remove measure model call when confidence level is low
nutfdt Jul 24, 2024
f2491ab
test: :white_check_mark: update firearm-fiability e2e test
nutfdt Jul 24, 2024
abfed0a
feat: :sparkles: add email client with local email server
thomashbrnrd Jul 17, 2024
0d7b876
feat: :sparkles: add endpoint to contact experts via email
thomashbrnrd Jul 23, 2024
cb3ceaa
refactor: :recycle: rework signing key retrieval
thomashbrnrd Jul 26, 2024
69dde13
feat: :sparkles: add pictures as email attachements
thomashbrnrd Jul 31, 2024
9373560
fix: :lock: set server_tokens to off in nginx conf
thomashbrnrd Aug 1, 2024
e05ae0f
Refactor expertise form
nutfdt Jun 23, 2024
3cb4fde
feat: :sparkles: finalize expert form contact with email attachment
nutfdt Aug 5, 2024
860a81f
Merge branch 'develop' into expert-contact-newbackend
nutfdt Aug 5, 2024
7e9057d
feat: :sparkles: add email client with local email server
thomashbrnrd Jul 17, 2024
16b250d
feat: :sparkles: add endpoint to contact experts via email
thomashbrnrd Jul 23, 2024
3c29b9c
refactor: :recycle: rework signing key retrieval
thomashbrnrd Jul 26, 2024
3a1431c
feat: :sparkles: add pictures as email attachements
thomashbrnrd Jul 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ jobs:
env:
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1
services:
mailpit:
image: axllent/mailpit
ports:
- 1025:1025
env:
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1

test-frontend-format:
name: Test Frontend Formatting
Expand Down
1 change: 1 addition & 0 deletions backend/src/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from datetime import datetime
from smtplib import SMTP
from smtplib import SMTP

import boto3
from fastapi.security import OpenIdConnect
Expand Down
4 changes: 4 additions & 0 deletions backend/src/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import time
from typing import Annotated, Union
from typing import Annotated, Union
from uuid import uuid4

from basegun_ml.classification import get_typology
Expand All @@ -11,6 +12,7 @@
BackgroundTasks,
Cookie,
Depends,
Depends,
File,
Form,
HTTPException,
Expand All @@ -24,6 +26,8 @@
from .config import APP_VERSION, S3_PREFIX, TYPOLOGIES_MEASURED, get_base_logs
from .models import EmailData
from .utils import get_current_user, send_mail, upload_image
from .models import EmailData
from .utils import get_current_user, send_mail, upload_image

router = APIRouter(prefix="/api")

Expand Down
2 changes: 1 addition & 1 deletion backend/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def get_current_user(token: Annotated[str, Depends(OAUTH2_SCHEME)]):
token.split()[1],
PUBLIC_KEY,
algorithms=["RS256"],
audience=["master-realm", "account"],
# audience=["master-realm", "account"],
)
except jwt.InvalidTokenError:
raise credentials_exception
1 change: 1 addition & 0 deletions backend/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def test_headers(self):
assert header_to_add["name"].lower() in CURRENT_HEADERS



class TestUpload:
def test_revolver_without_card(self):
with open("./tests/revolver.jpg", "rb") as f:
Expand Down
52 changes: 52 additions & 0 deletions frontend/src/api/api-client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* eslint-disable camelcase */
import axios from "axios";
import {
ASK_FOR_OPINION_ROUTE,
IDENTIFICATION_DUMMY_ROUTE,
IDENTIFICATION_FEEDBACK_ROUTE,
TUTORIAL_FEEDBACK_ROUTE,
UPLOAD_PHOTO_FOR_DETECTION_ROUTE,
} from "./api-routes";

export const uploadPhotoForDetection = async (file: File) => {
const fd = new FormData();
fd.append("image", file, file.name);
fd.append("date", "" + Date.now() / 1000); // date.now gives in milliseconds, convert to seconds

const { data } = await axios.post(UPLOAD_PHOTO_FOR_DETECTION_ROUTE, fd);
return data;
};

export const sendTutorialFeedback = async (feedback: any) => {
const { data } = await axios.post(TUTORIAL_FEEDBACK_ROUTE, feedback);
return data;
};

export const sendIdentificationFeedback = async (feedbackData: any) => {
const { data } = await axios.post(
IDENTIFICATION_FEEDBACK_ROUTE,
feedbackData,
);
return data;
};

export const sendIdentificationDummyFeedback = async (feedbackDummy: any) => {
const { data } = await axios.post(IDENTIFICATION_DUMMY_ROUTE, feedbackDummy);
return data;
};

export const sendExpertiseForm = async (
feedbackExpert: any,
accessToken: string,
) => {
try {
const { data } = await axios.post(ASK_FOR_OPINION_ROUTE, feedbackExpert, {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
return data;
} catch (error) {
console.error("Erreur lors de l'envoi du formulaire :", error);
}
};
5 changes: 5 additions & 0 deletions frontend/src/api/api-routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const UPLOAD_PHOTO_FOR_DETECTION_ROUTE = "/upload";
export const TUTORIAL_FEEDBACK_ROUTE = "/tutorial-feedback";
export const IDENTIFICATION_FEEDBACK_ROUTE = "/identification-feedback";
export const IDENTIFICATION_DUMMY_ROUTE = "/identification-dummy";
export const ASK_FOR_OPINION_ROUTE = "/expert-contact";
2 changes: 1 addition & 1 deletion frontend/src/components/ContactExpert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
href="#"
icon="ri-alert-line"
label="Contacter un expert"
@click="$router.push({ name: 'ExpertSituationGN' })"
@click="$router.push({ name: 'ExpertSituation' })"
/>
</div>
</template>
Expand Down
57 changes: 35 additions & 22 deletions frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { clearLocalStorage } from "@/utils/storage-utils.js";
import { mgr } from "@/utils/authentication";

import MissingCardPage from "@/views/MissingCardPage.vue";
import ExpertiseForm from "@/views/GuideAskingExpertise/ExpertiseForm.vue";

const HomePage = () => import("@/views/HomePage.vue");
const StartPage = () => import("@/views/StartPage.vue");
Expand Down Expand Up @@ -194,30 +195,33 @@ const routes: RouteRecordRaw[] = [
wholeLogo: true,
},
},

// tutorial to contact expert
{
path: "/guide-contact-pn",
name: "ExpertSituationPN",
path: "/guide-contact",
name: "ExpertSituation",
component: ExpertSituation,
beforeEnter: (to, from, next) => {
mgr.getUser().then((user) => {
console.log(user);
if (user === null) {
mgr.signinRedirect();
} else {
next();
}
});
},
},
{
path: "/guide-contact-gn",
name: "ExpertSituationGN",
component: ExpertSituation,
beforeEnter: (to, from) => {
path: "/guide-demande-expertise",
name: "ExpertiseForm",
component: ExpertiseForm,
beforeEnter: (to, from, next) => {
mgr.getUser().then((user) => {
console.log(user);
if (user === null)
mgr
.signinRedirect()
.then((data) => console.log(data))
.catch((err) => {
console.log(err);
return {
name: "PageNotFound",
};
});
if (user === null) {
mgr.signinRedirect();
} else {
next();
}
});
},
},
Expand All @@ -234,10 +238,19 @@ const routes: RouteRecordRaw[] = [
{
path: "callback",
name: "AuthCallback",
beforeEnter: (to, from) => {
mgr.signinCallback();
mgr.getUser().then((user) => console.log(user));
return { name: "ExpertSituationGN" };
beforeEnter: async (to, from, next) => {
try {
await mgr.signinRedirectCallback();
const user = await mgr.getUser();
if (user !== null) {
next({ name: "ExpertSituation" });
} else {
next({ name: "AuthRedirect" });
}
} catch (error) {
console.error("Erreur signin callback:", error);
next({ name: "AuthRedirect" });
}
},
},
],
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/utils/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export const mgr = new UserManager({
authority: import.meta.env.VITE_OIDC_AUTHORITY,
client_id: import.meta.env.VITE_OIDC_CLIENT_ID,
redirect_uri: `${FRONTEND_URL}/auth/callback`,
silent_redirect_uri: `${FRONTEND_URL}`,
post_logout_redirect_uri: `${FRONTEND_URL}`,
response_type: "code",
scope: "openid profile email",
automaticSilentRenew: false,
});
Loading