Skip to content

Commit

Permalink
ENH Update folders + namespaces, remove unused class
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jun 9, 2021
1 parent 4d58deb commit b8afcdd
Show file tree
Hide file tree
Showing 37 changed files with 66 additions and 225 deletions.
9 changes: 2 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
version: ~> 1.0

import:
- silverstripe/silverstripe-travis-shared:config/provision/standard-jobs-fixed-behat-npm.yml
# TODO: uncomment 'range' when 4.8 branch is available, remove 'fixed' requirement above
# - silverstripe/silverstripe-travis-shared:config/provision/standard-jobs-range-behat-npm.yml
- silverstripe/silverstripe-travis-shared:config/provision/standard-jobs-range-behat-npm.yml

env:
global:
- REQUIRE_RECIPE="4.x-dev"
# TODO: uncomment 4.8.x-dev requirement below when 4.8 branch is available, remove 4.x-dev requirement above
# require at minimum recipe 4.8 so that latest RememberLoginHash logic is available
# - REQUIRE_RECIPE="4.8.x-dev || "
- REQUIRE_RECIPE="4.8.x-dev || "
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Read [Saved User Logins](https://docs.silverstripe.org/en/4/developer_guides/sec
Non-persisted login sessions (those where the user hasn’t ticked “remember me”) should expire after a period of inactivity, so that they’re removed from the list of active sessions even if the user closes their browser without completing the “log out” action. The length of time before expiry matches the `SilverStripe\Control\Session.timeout` value if one is set, otherwise falling back to a default of one hour. This default can be changed via the following config setting:

```yml
SilverStripe\SessionManager\Model\LoginSession:
SilverStripe\SessionManager\Models\LoginSession:
default_session_lifetime: 3600 # Default value: 1 hour in seconds
```

Expand Down
2 changes: 1 addition & 1 deletion _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ SilverStripe\Core\Injector\Injector:
SilverStripe\Control\Director:
properties:
Middlewares:
LoginSessionMiddleware: '%$SilverStripe\SessionManager\Control\LoginSessionMiddleware'
LoginSessionMiddleware: '%$SilverStripe\SessionManager\Middleware\LoginSessionMiddleware'
---
Name: session-manager-rememberloginhash
After: '#coreauthentication'
Expand Down
7 changes: 7 additions & 0 deletions _config/routes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
Name: session-manager-routes
After: '#coreroutes'
---
SilverStripe\Control\Director:
rules:
'loginsession//remove/$ID': SilverStripe\SessionManager\Controllers\LoginSessionController
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import i18n from 'i18n';

function createEndpoint(logOutEndpoint) {
return backend.createEndpointFetcher({
url: `${logOutEndpoint}/:id`,
url: `${logOutEndpoint}/:id`.replace('//', '/'),
method: 'delete',
payloadSchema: {
id: { urlReplacement: ':id', remove: true },
Expand Down
4 changes: 2 additions & 2 deletions doc/en/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ You should also consider the relevant privacy legislation in the jurisdiction yo

## Customising the permissions for `LoginSession`

`SilverStripe\SessionManager\Model\LoginSession` is the object that tracks the users' sessions. By altering the permission logic on this object, you can allow some users to manage other users' sessions. The two permissions you'll most likely want to change are `canView` and `canDelete`. You can customise `canEdit` and `canCreate` as well, but the use case for doing so is less clear.
`SilverStripe\SessionManager\Models\LoginSession` is the object that tracks the users' sessions. By altering the permission logic on this object, you can allow some users to manage other users' sessions. The two permissions you'll most likely want to change are `canView` and `canDelete`. You can customise `canEdit` and `canCreate` as well, but the use case for doing so is less clear.

### Creating an extension for `LoginSession`

Expand Down Expand Up @@ -61,7 +61,7 @@ class LoginSessionExtension extends DataExtension
Add this bit of code to your project's YML configuration te enable your extension.

```yml
SilverStripe\SessionManager\Model\LoginSession:
SilverStripe\SessionManager\Models\LoginSession:
extensions:
- My\App\LoginSessionExtension
```
File renamed without changes.
10 changes: 4 additions & 6 deletions lang/en.yml → images/lang/en.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
en:
SilverStripe\SessionManager\Control\LoginSessionController:
MENUTITLE: SilverStripe\SessionManager\Control\LoginSessionController
SilverStripe\SessionManager\Controllers\LoginSessionController:
MENUTITLE: SilverStripe\SessionManager\Controllers\LoginSessionController
REMOVE_FAILURE: 'Something went wrong.'
REMOVE_PERMISSION: 'You do not have permission to delete this record.'
REMOVE_SUCCESS: 'Successfully logged out of device.'
SilverStripe\SessionManager\Extensions\MemberExtension:
DEVICES: 'Authenticated devices'
LEARN_MORE: 'Learn more'
SilverStripe\SessionManager\Forms\GridFieldRevokeLoginSessionAction:
DeletePermissionsFailure: 'No delete permissions'
SilverStripe\SessionManager\Job\GarbageCollectionJob:
SilverStripe\SessionManagers\GarbageCollectionJob:
TITLE: 'Session manager garbage collection'
SilverStripe\SessionManager\Model\LoginSession:
SilverStripe\SessionManager\Models\LoginSession:
BROWSER_ON_OS: '{browser} on {os}.'
PLURALNAME: 'Login Sessions'
PLURALS:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
<?php

namespace SilverStripe\SessionManager\Control;
namespace SilverStripe\SessionManager\Controllers;

use Exception;
use SilverStripe\Admin\LeftAndMain;
use SilverStripe\Control\Controller;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Security\SecurityToken;
use SilverStripe\SessionManager\Model\LoginSession;
use SilverStripe\SessionManager\Models\LoginSession;

// TODO: move this to Controllers folder and extend Controller instead of LeftAndMain
class LoginSessionController extends LeftAndMain
class LoginSessionController extends Controller
{
private static $url_segment = 'loginsession';

// TODO: remove this when no longer extending LeftAndMain
private static $ignore_menuitem = true;

private static $url_handlers = [
'DELETE remove/$ID' => 'remove',
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Security\Member;
use SilverStripe\SessionManager\FormField\SessionManagerField;
use SilverStripe\SessionManager\Model\LoginSession;
use SilverStripe\SessionManager\FormFields\SessionManagerField;
use SilverStripe\SessionManager\Models\LoginSession;

/**
* Augment `Member` to allow relationship to the LoginSession DataObject
Expand Down
2 changes: 1 addition & 1 deletion src/Extensions/QueuedJobDescriptorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace SilverStripe\SessionManager\Extensions;

use SilverStripe\Core\Extension;
use SilverStripe\SessionManager\Job\GarbageCollectionJob;
use SilverStripe\SessionManager\Jobs\GarbageCollectionJob;

class QueuedJobDescriptorExtension extends Extension
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Core\Extension;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\SessionManager\Model\LoginSession;
use SilverStripe\SessionManager\Models\LoginSession;
use SilverStripe\SessionManager\Security\LogInAuthenticationHandler;

class RememberLoginHashExtension extends Extension
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace SilverStripe\SessionManager\FormField;
namespace SilverStripe\SessionManager\FormFields;

use SilverStripe\Forms\FormField;
use SilverStripe\ORM\DataObject;
use SilverStripe\Security\Member;
use SilverStripe\SessionManager\Control\LoginSessionController;
use SilverStripe\SessionManager\Model\LoginSession;
use SilverStripe\SessionManager\Controllers\LoginSessionController;
use SilverStripe\SessionManager\Models\LoginSession;
use SilverStripe\View\ViewableData;

class SessionManagerField extends FormField
Expand Down
136 changes: 0 additions & 136 deletions src/Forms/GridFieldRevokeLoginSessionAction.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace SilverStripe\SessionManager\Job;
namespace SilverStripe\SessionManager\Jobs;

use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\SessionManager\Service\GarbageCollectionService;
use SilverStripe\SessionManager\Services\GarbageCollectionService;
use Symbiote\QueuedJobs\DataObjects\QueuedJobDescriptor;
use Symbiote\QueuedJobs\Services\AbstractQueuedJob;
use Symbiote\QueuedJobs\Services\QueuedJob;
Expand Down
5 changes: 2 additions & 3 deletions src/Middleware/LoginSessionMiddleware.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?php

namespace SilverStripe\SessionManager\Control;
namespace SilverStripe\SessionManager\Middleware;

use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Control\Middleware\HTTPMiddleware;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\ORM\Connect\DatabaseException;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Security\IdentityStore;
use SilverStripe\Security\RememberLoginHash;
use SilverStripe\Security\Security;
use SilverStripe\SessionManager\Model\LoginSession;
use SilverStripe\SessionManager\Models\LoginSession;
use SilverStripe\SessionManager\Security\LogInAuthenticationHandler;

class LoginSessionMiddleware implements HTTPMiddleware
Expand Down
2 changes: 1 addition & 1 deletion src/Model/LoginSession.php → src/Models/LoginSession.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace SilverStripe\SessionManager\Model;
namespace SilverStripe\SessionManager\Models;

use SilverStripe\Control\Controller;
use SilverStripe\Control\HTTPRequest;
Expand Down
2 changes: 1 addition & 1 deletion src/Security/LogInAuthenticationHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use SilverStripe\Security\AuthenticationHandler;
use SilverStripe\Security\Member;
use SilverStripe\Security\RememberLoginHash;
use SilverStripe\SessionManager\Model\LoginSession;
use SilverStripe\SessionManager\Models\LoginSession;

/**
* This is separate to LogOutAuthenticationHandler so that it can be registered with
Expand Down
3 changes: 1 addition & 2 deletions src/Security/LogOutAuthenticationHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Security\AuthenticationHandler;
use SilverStripe\Security\Member;
use SilverStripe\Security\RememberLoginHash;
use SilverStripe\Security\Security;
use SilverStripe\SessionManager\Model\LoginSession;
use SilverStripe\SessionManager\Models\LoginSession;

/**
* This is separate to LogInAuthenticationHandler so that it can be registered with
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace SilverStripe\SessionManager\Service;
namespace SilverStripe\SessionManager\Services;

use SilverStripe\Core\Injector\Injectable;
use SilverStripe\Security\RememberLoginHash;
use SilverStripe\SessionManager\Model\LoginSession;
use SilverStripe\SessionManager\Models\LoginSession;

class GarbageCollectionService
{
Expand Down
2 changes: 1 addition & 1 deletion src/Tasks/GarbageCollectionTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace SilverStripe\Tasks;

use SilverStripe\Dev\BuildTask;
use SilverStripe\SessionManager\Service\GarbageCollectionService;
use SilverStripe\SessionManager\Services\GarbageCollectionService;

class GarbageCollectionTask extends BuildTask
{
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/src/FixtureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use SilverStripe\BehatExtension\Context\FixtureContext as BaseFixtureContext;
use SilverStripe\Control\Controller;
use SilverStripe\Security\Member;
use SilverStripe\SessionManager\Model\LoginSession;
use SilverStripe\SessionManager\Models\LoginSession;

/**
* Context used to create fixtures in the SilverStripe ORM.
Expand Down
Loading

0 comments on commit b8afcdd

Please sign in to comment.