Skip to content

Commit 7e465df

Browse files
fix(pronote): INTEG-1023, update Pronote connection to use auth/redirect like other connectors and remove profile exception for improved redirection
1 parent d71d3aa commit 7e465df

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

src/framework/modules/pronote/service/redirect.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,24 @@
11
import { I18n } from '~/app/i18n';
22
import { AuthLoggedAccount } from '~/framework/modules/auth/model';
33
import { openUrl } from '~/framework/util/linking';
4-
import { signedFetch } from '~/infra/fetchWithCache';
5-
6-
const profileMap = {
7-
PERSONNEL: 'direction',
8-
RELATIVE: 'parent',
9-
STUDENT: 'eleve',
10-
TEACHER: 'professeur',
11-
};
124

135
const getRedirectUrl = (session: AuthLoggedAccount, connectorAddress: string, pageId?: string) => {
146
const getSlash = (link: string) => {
157
const service = decodeURIComponent(link);
168
return service.charAt(service.length - 1) === '/' ? '' : '%2F';
179
};
18-
let link = `${session.platform.url}/cas/oauth/login?service=${encodeURIComponent(connectorAddress)}`;
19-
const role = profileMap[session.user.type.toUpperCase()];
20-
// INTEG-1023: Not every PERSONNEL is a direction, so we don't add anything for them
21-
if (role !== profileMap.PERSONNEL) {
22-
link += `${getSlash(link)}mobile.${role}.html`;
23-
}
10+
let link = `${session.platform.url}/auth/redirect?url=${encodeURIComponent(connectorAddress)}`;
11+
12+
link += `${getSlash(link)}mobile.html`;
13+
2414
if (pageId) {
2515
link += encodeURIComponent(`?page=${pageId}`);
2616
}
2717
return link;
2818
};
2919

3020
export default async (session: AuthLoggedAccount, connectorAddress: string, pageId?: string, dryRun?: boolean) => {
31-
const intermediateResponse = await signedFetch(getRedirectUrl(session, connectorAddress, pageId));
32-
const finalUrl = intermediateResponse.headers.get('location');
21+
const finalUrl = getRedirectUrl(session, connectorAddress, pageId);
3322
if (dryRun) return finalUrl ?? undefined;
3423
openUrl(finalUrl ?? undefined, {
3524
error: I18n.get('pronote-redirect-error-message'),

0 commit comments

Comments
 (0)