Skip to content
Projects
Groups
Snippets
Help
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project overview
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
262
Merge Requests
28
CI / CD
Security & Compliance
Packages
Wiki
Snippets
Members
Collapse sidebar
Close sidebar
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
8954440c
Commit
8954440c
authored
1 hour ago
by
Ben Hayward
Browse files
Options
Download
Surge token deletion on logout. #1270
parent
3efa2421
fix/logout-surge-token-deletion-1270
1 merge request
!436
Surge token deletion on logout #1270
Pipeline
#107889461
passed with stages
in 7 minutes and 56 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
5 deletions
+68
-5
Controllers/api/v1/notifications.php
View file @
8954440c
...
...
@@ -146,10 +146,12 @@ class notifications implements Interfaces\Api
'service'
=>
$service
,
'token'
=>
$passed_token
]);
Core\Session
::
getLoggedInUser
()
->
setSurgeToken
(
$token
)
->
save
();
(
new
Core\Data\Call
(
'entities'
))
->
insert
(
static
::
getCurrentUserGuid
(),
[
'surge_token'
=>
$token
]);
break
;
break
;
}
return
Factory
::
response
([]);
...
...
This diff is collapsed.
Core/Sessions/Manager.php
View file @
8954440c
...
...
@@ -8,6 +8,7 @@ namespace Minds\Core\Sessions;
use
Minds\Common\Cookie
;
use
Minds\Core
;
use
Minds\Core\Di\Di
;
use
Minds\Entities\User
;
use
Lcobucci\JWT
;
use
Lcobucci\JWT\Signer\Key
;
use
Lcobucci\JWT\Signer\Rsa\Sha512
;
...
...
@@ -246,7 +247,15 @@ class Manager
public
function
destroy
(
$all
=
false
)
{
if
(
$this
->
session
)
{
$this
->
repository
->
delete
(
$this
->
session
,
$all
);
if
(
!
$this
->
user
)
{
// If no user set grab from session.
$this
->
user
=
new
User
(
$this
->
session
->
getLoggedInUser
());
}
$this
->
user
->
setSurgeToken
(
''
)
// Delete push notification token.
->
save
();
$this
->
repository
->
delete
(
$this
->
session
,
$all
);
// Delete from repository.
}
$this
->
cookie
...
...
This diff is collapsed.
Entities/User.php
View file @
8954440c
...
...
@@ -62,6 +62,7 @@ class User extends \ElggUser
$this
->
attributes
[
'mode'
]
=
ChannelMode
::
OPEN
;
$this
->
attributes
[
'email_confirmation_token'
]
=
null
;
$this
->
attributes
[
'email_confirmed_at'
]
=
null
;
$this
->
attributes
[
'surge_token'
]
=
''
;
parent
::
initializeAttributes
();
}
...
...
@@ -1227,6 +1228,7 @@ class User extends \ElggUser
'toaster_notifications'
,
'mode'
,
'btc_address'
,
'surge_token'
,
]);
}
...
...
@@ -1394,4 +1396,26 @@ class User extends \ElggUser
return
$this
;
}
/**
* Gets the Surge Token of the user for push notifications.
*
* @return string Token.
*/
public
function
getSurgeToken
()
:
string
{
return
(
string
)
$this
->
surge_token
??
''
;
}
/**
* Sets the Surge Token of the user for push notifications.
*
* @param string $token - the token string.
* @return User instance of $this for chaining.
*/
public
function
setSurgeToken
(
string
$token
=
''
)
:
User
{
$this
->
surge_token
=
$token
;
return
$this
;
}
}
This diff is collapsed.
Spec/Core/Sessions/ManagerSpec.php
View file @
8954440c
...
...
@@ -324,7 +324,8 @@ YSoKTsWFlvr9YG4o6R2ktgzKJ5ofiGTz5e2wLzP3a0ma8vGNke4Q
public
function
it_should_destroy_session_on_client_and_server
(
Repository
$repository
,
Cookie
$cookie
Cookie
$cookie
,
\Minds\Entities\User
$user
)
{
$this
->
beConstructedWith
(
$repository
,
...
...
@@ -343,6 +344,19 @@ YSoKTsWFlvr9YG4o6R2ktgzKJ5ofiGTz5e2wLzP3a0ma8vGNke4Q
$repository
->
delete
(
'mock_session_id'
);
$user
->
guid
=
123
;
$this
->
setUser
(
$user
);
$user
->
setSurgeToken
(
''
)
->
shouldBeCalled
()
->
willReturn
(
$user
);
$user
->
save
()
->
shouldBeCalled
()
->
willReturn
(
null
);
$cookie
->
setName
(
'minds_sess'
)
->
shouldBeCalled
()
->
willReturn
(
$cookie
);
...
...
This diff is collapsed.
Spec/Entities/UserSpec.php
View file @
8954440c
...
...
@@ -71,4 +71,18 @@ class UserSpec extends ObjectBehavior
$export
=
$this
->
export
()
->
getWrappedObject
();
expect
(
$export
[
'mode'
])
->
shouldEqual
(
ChannelMode
::
OPEN
);
}
public
function
it_should_get_surge_token
()
{
$token
=
'11111'
;
$this
->
surge_token
=
$token
;
$this
->
getSurgeToken
()
->
shouldReturn
(
$token
);
}
public
function
it_should_set_surge_token
()
{
$token
=
'11111'
;
$this
->
setSurgeToken
(
$token
)
->
shouldReturnAnInstanceOf
(
'Minds\Entities\User'
);
$this
->
getSurgeToken
()
->
shouldReturn
(
$token
);
}
}
This diff is collapsed.
Please
register
or
sign in
to comment