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

Revert "refactor: ♻️ use env variable for contact numbers" #591

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions backend/src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,3 @@ def get_base_logs(user_agent, user_id: str) -> dict:
)

OAUTH2_SCHEME = OpenIdConnect(openIdConnectUrl=os.environ["OIDC_CONFIG_URL"])

# Phone numbers
PHONE_NUMBER = os.environ.get("IRCGN_PHONE")
CELLPHONE_NUMBER = os.environ.get("IRCGN_CELLPHONE")
25 changes: 1 addition & 24 deletions backend/src/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,11 @@
Request,
Response,
UploadFile,
status,
)
from fastapi.responses import PlainTextResponse
from user_agents import parse

from .config import (
APP_VERSION,
CELLPHONE_NUMBER,
PHONE_NUMBER,
S3_PREFIX,
TYPOLOGIES_MEASURED,
get_base_logs,
)
from .config import APP_VERSION, S3_PREFIX, TYPOLOGIES_MEASURED, get_base_logs
from .utils import get_current_user, send_mail, upload_image

router = APIRouter(prefix="/api")
Expand All @@ -45,21 +37,6 @@ def version():
return APP_VERSION


@router.get("/contact-details")
async def phone_number(
current_user: Annotated[dict, Depends(get_current_user)],
):
if current_user.get("idp") != "proxyma":
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Access forbidden: Invalid idp",
)
return {
"phone": PHONE_NUMBER,
"cellphone": CELLPHONE_NUMBER,
}


@router.post("/upload")
async def imageupload(
request: Request,
Expand Down
13 changes: 0 additions & 13 deletions backend/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,3 @@ def test_403(self):
response = client.post("/api/expert-contact")
response.data = response.json()
assert response.status_code == 403


class TestExpertDetails:
@pytest.mark.skip("Need to authenticate to run that test.")
def test_success(self):
response = client.get("/api/contact-details")
response.data = response.json()
assert response.status_code == 200

def test_403(self):
response = client.get("/api/contact-details")
response.data = response.json()
assert response.status_code == 403
10 changes: 0 additions & 10 deletions frontend/src/api/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
IDENTIFICATION_FEEDBACK_ROUTE,
TUTORIAL_FEEDBACK_ROUTE,
UPLOAD_PHOTO_FOR_DETECTION_ROUTE,
GET_IRCGN_NUMBERS_ROUTE,
} from "./api-routes";

export const uploadPhotoForDetection = async (file: File) => {
Expand Down Expand Up @@ -47,12 +46,3 @@ export const sendExpertiseForm = async (data: any, accessToken: string) => {
},
});
};

export const getContactDetails = async (accessToken: string) => {
const { data } = await axios.get(GET_IRCGN_NUMBERS_ROUTE, {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
return data;
};
1 change: 0 additions & 1 deletion frontend/src/api/api-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ 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";
export const GET_IRCGN_NUMBERS_ROUTE = "/contact-details";
57 changes: 27 additions & 30 deletions frontend/src/views/GuideContactExpert/ExpertSituation.vue
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
<script lang="ts" setup>
import { ref } from "vue";
import { DsfrButton } from "@gouvminint/vue-dsfr";
import { useRouter } from "vue-router";
import { DateTime } from "luxon";
import { mgr } from "@/utils/authentication";
import { getContactDetails } from "@/api/api-client";

const user = ref<any>(null);
const user = ref(Object || null);
mgr.getUser().then((data) => (user.value = data));

const getIRCGNDetails = async () => {
try {
const response = await getContactDetails(user.value?.access_token);
IRCGN.fixe = response.cellphone;
IRCGN.phone = response.phone;
} catch (error) {
console.error(
"Erreur lors de la récupération des détails de contact :",
error,
);
}
};

onMounted(async () => {
user.value = await mgr.getUser();

await getIRCGNDetails();
});
const priority = ref("");

const IRCGN = {
fixe: "",
phone: "",
email: "[email protected]",
fixe: "01 78 47 31 46",
phone: "06 07 98 40 09",
};
const showIRCGNModal = ref(false);

Expand All @@ -52,15 +37,15 @@ const currentPhone = computed(() => {
<div class="text-center mt-5 p-3">
<h1>
<VIcon name="ri-arrow-right-line" scale="1.7" />
<span v-if="user?.profile?.idp === 'proxyma'"
>Contacter un expert de l'IRCGN</span
>
<span v-if="user.profile.idp === 'proxyma'">
Contacter un expert de l'IRCGN
</span>
<span v-else>Contacter un expert en arme</span>
</h1>
<div v-if="user?.profile?.idp === 'proxyma'">
<div v-if="user.profile.idp === 'proxyma'">
<p>Sélectionnez votre situation actuelle :</p>
</div>
<div v-else>
<div v-if="authIDP === 'cheops'">
<DsfrAlert type="error" title="Avertissement">
Basegun ne fournit pas de
<span class="font-bold"
Expand All @@ -84,7 +69,7 @@ const currentPhone = computed(() => {
</div>
</div>
</div>
<div v-if="user?.profile?.idp === 'proxyma'">
<div v-if="user.profile.idp === 'proxyma'">
<div class="fr-grid-row">
<div class="fr-col-12 fr-col-lg-6 mx-auto">
<div class="fr-grid-row">
Expand Down Expand Up @@ -119,21 +104,33 @@ const currentPhone = computed(() => {
permanence de l'IRCGN.<br /><br />
<span class="font-bold">{{ currentPhone }}</span>
</p>
<p v-if="priority === 'low'">
Veuilez cliquer sur l'adresse mail ci-dessous pour envoyer un
mail pré-rempli à l'IRCGN : <br /><br />
<span class="font-bold"
><a :href="buildMailto(IRCGN.email)">{{
IRCGN.email
}}</a></span
>
</p>
</div>
<div class="fr-col-11 fr-col-lg-6 footer-actions mx-auto">
<DsfrButton
class="m-1 flex justify-center"
icon="ri-arrow-left-line"
label="Précédent"
@click="showIRCGNModal = false"
@click="
showIRCGNModal = false;
priority = '';
"
/>
</div>
</div>
</div>
</DsfrModal>
</Teleport>
</div>
<div v-if="user?.profile?.idp === 'proxyma'" class="fr-grid-row">
<div v-if="user.profile.idp === 'proxyma'" class="fr-grid-row">
<div class="fr-col text-center">
<div class="bg-purple p-8 fr-my-8w">
<p>Exemple de cas d'urgences :</p>
Expand Down
Loading