Merge pull request #12842 from overleaf/jpa-logout

[web] remove GET /logout endpoints

GitOrigin-RevId: 93f9498fdb66ece5028d90941aac50cda2737604
This commit is contained in:
Jakob Ackermann 2023-05-03 12:49:10 +01:00 committed by Copybot
parent d5242379f2
commit b0633b3a47
7 changed files with 6 additions and 34 deletions

View file

@ -60,7 +60,9 @@ async function settingsPage(req, res) {
const user = await UserGetter.promises.getUser(userId)
if (!user) {
// The user has just deleted their account.
return res.redirect('/logout')
return UserSessionsManager.revokeAllUserSessions({ _id: userId }, [], () =>
res.redirect('/')
)
}
res.render('user/settings', {
title: 'account_settings',
@ -151,10 +153,6 @@ const UserPagesController = {
res.render('user/one_time_login')
},
logoutPage(req, res) {
res.render('user/logout')
},
renderReconfirmAccountPage(req, res) {
const pageData = {
reconfirm_email: req.session.reconfirm_email,

View file

@ -263,7 +263,6 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) {
'/read-only/one-time-login'
)
webRouter.get('/logout', UserPagesController.logoutPage)
webRouter.post('/logout', UserController.logout)
webRouter.get('/restricted', AuthorizationMiddleware.restricted)

View file

@ -1,24 +0,0 @@
extends ../layout-marketing
block content
.content.content-alt
main.login-register-container#main-content
.card.login-register-card
.login-register-header
h1.login-register-header-heading #{translate("log_out")}
form.login-register-form(
data-ol-async-form,
name="logoutForm",
action='/logout',
method="POST"
data-ol-auto-submit
)
input(name='_csrf', type='hidden', value=csrfToken)
+formMessages()
.actions
button#submit-logout.btn-primary.btn.btn-block(
data-ol-disabled-inflight,
type='submit'
)
span(data-ol-inflight="idle" aria-label=translate('log_out')) #{translate('log_out')}
span(hidden data-ol-inflight="pending" aria-label=translate("logging_out")) #{translate('logging_out')}…

View file

@ -55,7 +55,7 @@ function LeaveModalForm({
},
})
.then(() => {
location.assign('/login')
location.assign('/')
})
.catch(setError)
.finally(() => {

View file

@ -850,7 +850,6 @@
"log_viewer_error": "There was a problem displaying this projects compilation errors and logs.",
"logged_in_with_email": "You are currently logged in to <b>__appName__</b> with the email <b>__email__</b>.",
"logging_in": "Logging in",
"logging_out": "Logging out",
"login": "Login",
"login_error": "Login error",
"login_failed": "Login failed",

View file

@ -89,7 +89,7 @@ describe('<LeaveModalForm />', function () {
sinon.assert.calledTwice(setInFlight)
sinon.assert.calledWithMatch(setInFlight, false)
sinon.assert.calledOnce(assignStub)
sinon.assert.calledWith(assignStub, '/login')
sinon.assert.calledWith(assignStub, '/')
})
})

View file

@ -22,7 +22,7 @@ async function run({ assertHasStatusCode, loginCsrfToken, request }) {
}
async function cleanup({ assertHasStatusCode, getCsrfTokenFor, request }) {
const logoutCsrfToken = await getCsrfTokenFor('/logout')
const logoutCsrfToken = await getCsrfTokenFor('/project')
const response = await request('/logout', {
method: 'POST',
headers: {