Skip to content

Commit

Permalink
add button logout
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitSerrano committed May 28, 2024
1 parent b85964a commit c243e84
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ ENCRYPT_SECRET=un_secret_avec_exactement_64_bit

# Use OIDC auth instead of audioconf's magiclink auth
#OIDC_PROVIDER_URL=
#OIDC_PROVIDER_LOGOUT_URL=
#OIDC_CLIENT_ID=
#OIDC_CLIENT_SECRET=

Expand Down
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ config.STATS_EXTERNAL_DASHBOARD_URL = process.env.STATS_EXTERNAL_DASHBOARD_URL


config.OIDC_PROVIDER_URL = process.env.OIDC_PROVIDER_URL
config.OIDC_PROVIDER_LOGOUT_URL = process.env.OIDC_PROVIDER_LOGOUT_URL
config.OIDC_CLIENT_ID = process.env.OIDC_CLIENT_ID
config.OIDC_CLIENT_SECRET = process.env.OIDC_CLIENT_SECRET
config.OIDC_ACR_VALUES = process.env.OIDC_ACR_VALUES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ module.exports.startAuth = async (req, res) => {

res.redirect(authRequest.redirectUrl)
}

module.exports.logout = async(req, res) => {
console.log(req.session)
return res.redirect(`/`)
}
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const dashboardController = require("./controllers/dashboardController")
const format = require("./lib/format")
const createConfController = require("./controllers/createConfController")
const landingController = require("./controllers/landingController")
const startAuthController = require("./controllers/startAuthController")
const userController = require("./controllers/userController")
const statusController = require("./controllers/statusController")
const stats = require("./lib/stats")
const urls = require("./urls")
Expand Down Expand Up @@ -75,7 +75,8 @@ app.use(function(req, res, next){

app.get(urls.landing, landingController.getLanding)

app.post(urls.startAuth, startAuthController.startAuth)
app.post(urls.startAuth, userController.startAuth)
app.post(urls.logout, userController.logout)

app.get(urls.validationEmailSent, (req, res) => {
res.render("validationEmailSent", {
Expand Down Expand Up @@ -139,6 +140,8 @@ app.get(urls.faq, (req, res) => {
})
})

app.get(urls.logout, userController.logout)

app.get(urls.status, statusController.getStatus)

app.use(Sentry.Handlers.errorHandler())
Expand Down
2 changes: 2 additions & 0 deletions lib/oidcAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ module.exports.finishAuth = async (req) => {
return { error: "L'identification a échoué. Entrez votre adresse mail ci-dessous pour recommencer." }
}
const email = userinfo.email

req.session.id_token_hint = tokenSet.id_token

return {
email,
Expand Down
2 changes: 1 addition & 1 deletion test/startAuthControllerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const oidcAuth = require("../lib/oidcAuth")
const sinon = require("sinon")
const urls = require("../urls")

describe("startAuthController", function() {
describe("userController", function() {

describe("using oidcAuth", function() {
let oidcClientStub
Expand Down
1 change: 1 addition & 0 deletions urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ module.exports = {
participantAction: '/dashboard/:participantId/:action',
dashboard: '/dashboard',
status: '/api/status',
logout: '/api/logout'
}
3 changes: 3 additions & 0 deletions views/partials/header.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
<li>
<%- include('dark-mode-switch') -%>
</li>
<li class="fr-link fr-icon-logout-box-r-line fr-icon">
<a href="<%= urls.logout %>">Se déconnecter</a>
</li>
</ul>
</div>
</div>
Expand Down

0 comments on commit c243e84

Please sign in to comment.