mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-10 10:56:31 +00:00
Merge pull request #5590 from overleaf/tm-show-current-session-2
Show current session on user sessions page GitOrigin-RevId: fd748207905f600ca3102db6a208a994b089ca97
This commit is contained in:
parent
164ea5735f
commit
307e151d6d
4 changed files with 33 additions and 0 deletions
|
@ -137,6 +137,10 @@ const UserPagesController = {
|
|||
sessionsPage(req, res, next) {
|
||||
const user = SessionManager.getSessionUser(req.session)
|
||||
logger.log({ userId: user._id }, 'loading sessions page')
|
||||
const currentSession = {
|
||||
ip_address: user.ip_address,
|
||||
session_created: user.session_created,
|
||||
}
|
||||
UserSessionsManager.getAllUserSessions(
|
||||
user,
|
||||
[req.sessionID],
|
||||
|
@ -149,6 +153,7 @@ const UserPagesController = {
|
|||
}
|
||||
res.render('user/sessions', {
|
||||
title: 'sessions',
|
||||
currentSession,
|
||||
sessions,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -9,6 +9,19 @@ block content
|
|||
.page-header
|
||||
h1 #{translate("your_sessions")}
|
||||
|
||||
if currentSession.ip_address && currentSession.session_created
|
||||
h3 #{translate("current_session")}
|
||||
div
|
||||
table.table.table-striped
|
||||
thead
|
||||
tr
|
||||
th #{translate("ip_address")}
|
||||
th #{translate("session_created_at")}
|
||||
tr
|
||||
td #{currentSession.ip_address}
|
||||
td #{moment(currentSession.session_created).utc().format('Do MMM YYYY, h:mm a')} UTC
|
||||
|
||||
h3 #{translate("other_sessions")}
|
||||
div
|
||||
p.small
|
||||
| !{translate("clear_sessions_description")}
|
||||
|
|
|
@ -625,6 +625,8 @@
|
|||
"clear_sessions_success": "Sessions Cleared",
|
||||
"sessions": "Sessions",
|
||||
"manage_sessions": "Manage Your Sessions",
|
||||
"current_session": "Current Session",
|
||||
"other_sessions": "Other Sessions",
|
||||
"syntax_validation": "Code check",
|
||||
"history": "History",
|
||||
"joining": "Joining",
|
||||
|
|
|
@ -35,6 +35,8 @@ describe('UserPagesController', function () {
|
|||
_id: (this.user_id = 'kwjewkl'),
|
||||
features: {},
|
||||
email: 'joe@example.com',
|
||||
ip_address: '1.1.1.1',
|
||||
session_created: 'timestamp',
|
||||
thirdPartyIdentifiers: [
|
||||
{
|
||||
providerId: 'google',
|
||||
|
@ -168,6 +170,17 @@ describe('UserPagesController', function () {
|
|||
return this.UserPagesController.sessionsPage(this.req, this.res)
|
||||
})
|
||||
|
||||
it('should include current session data in the view', function (done) {
|
||||
this.res.render = (page, opts) => {
|
||||
expect(opts.currentSession).to.deep.equal({
|
||||
ip_address: '1.1.1.1',
|
||||
session_created: 'timestamp',
|
||||
})
|
||||
return done()
|
||||
}
|
||||
return this.UserPagesController.sessionsPage(this.req, this.res)
|
||||
})
|
||||
|
||||
it('should have called getAllUserSessions', function (done) {
|
||||
this.res.render = page => {
|
||||
this.UserSessionsManager.getAllUserSessions.callCount.should.equal(1)
|
||||
|
|
Loading…
Add table
Reference in a new issue