-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: separate types from routes files
- Loading branch information
Showing
10 changed files
with
52 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Exception } from '#models/exceptions'; | ||
|
||
export class AgentConnectLogoutFailedException extends Exception { | ||
constructor(args: { cause?: any }) { | ||
super({ | ||
...args, | ||
name: 'LogoutFailedException', | ||
}); | ||
} | ||
} | ||
|
||
export class AgentConnectFailedException extends Exception { | ||
constructor(args: { cause?: any }) { | ||
super({ | ||
name: 'AgentConnectionFailedException', | ||
...args, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,17 @@ | ||
import { agentConnectLogoutUrl } from '#clients/authentication/agent-connect/strategy'; | ||
import { Exception } from '#models/exceptions'; | ||
import logErrorInSentry from '#utils/sentry'; | ||
import { setPathFrom } from '#utils/session'; | ||
import withSession from '#utils/session/with-session'; | ||
import { NextResponse } from 'next/server'; | ||
import { AgentConnectLogoutFailedException } from '../agent-connect-types'; | ||
|
||
export const GET = withSession(async function logoutRoute(req) { | ||
try { | ||
await setPathFrom(req.session, req.headers.get('referer') || ''); | ||
const url = await agentConnectLogoutUrl(req); | ||
return NextResponse.redirect(url); | ||
} catch (e: any) { | ||
logErrorInSentry(new LogoutFailedException({ cause: e })); | ||
logErrorInSentry(new AgentConnectLogoutFailedException({ cause: e })); | ||
return NextResponse.redirect('/connexion/au-revoir'); | ||
} | ||
}); | ||
|
||
export class LogoutFailedException extends Exception { | ||
constructor(args: { cause?: any }) { | ||
super({ | ||
...args, | ||
name: 'LogoutFailedException', | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Exception } from '#models/exceptions'; | ||
|
||
export class FranceConnectFailedException extends Exception { | ||
constructor(args: { cause?: any }) { | ||
super({ | ||
name: 'FranceConnectFailedException', | ||
...args, | ||
}); | ||
} | ||
} | ||
|
||
export class FranceConnectLogoutFailedException extends Exception { | ||
constructor(args: { cause?: any }) { | ||
super({ | ||
...args, | ||
name: 'LogoutFailedException', | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters