Global Logout Module

Today with multiple applications being built using Drupal and with user's
accessing Drupal from different devices, a security feature that is must
needed is for the user to be able to monitor and manage the different sessions
through which he is using the application.

This module helps to manage a user's active logins.

The user can view his active logged in information such as Hostname, Accessed Time,
Browser and the platform (operating system).

active login info

Using session information this module can logout a user form all the devices with the
active logins. This page is available as a menu under main-menu and is built using views.

A menu called Global Logout is added to the User Menu.

Inspired by Google's Activity details feature.

Configuration:

Global Logout module is provided with a configuration page to manage with the "Global Logout" menu name.

active login info

Future Enhancements:

1. Location identifier.
2. Recently accessed device.
3. Mail alert on signing in new devices.

Clone Repository

git clone --branch 7.x-1.x http://git.drupal.org/sandbox/Anishnirmal/2645348.git global_logout

Comments

Anishnirmal created an issue. See original summary.

anishnirmal’s picture

Issue summary: View changes
arunkumark’s picture

Status: Needs review » Needs work

Hi Anishnirmal,

Please make your code more standard by following this documentation https://www.drupal.org/coding-standards

Fix the issue from
Automated Review:

Review your code on pareview.sh it shows exact standard for the drupal.

git clone --branch 7.x-1.x http://git.drupal.org/sandbox/Anishnirmal/2645348.git global_logout

atul4drupal’s picture

Hello Anishnirmal,

Few Suggstions :

global_logout.module file
1) At hook_user_login() you have defined two variable.
Its a standard practice to prefix all such variable with the module name as all such variables go into 'variable' table in DB.
2) In global_logout_all_devices()
$sql = "DELETE from {sessions} WHERE uid = " . $uid . "";
here $sql variable is not used any where, hence this should be removed.

3) where ever we use drupal_goto(), its a good practice to add exit(); statement in the following line.

4) Define the class in some separate file.

etc...

Rahul Seth’s picture

Automated Review

I ran your code against auto code sniffer at 'http://pareview.sh/pareview/httpgitdrupalorgsandboxanishnirmal2645348git'.

Git errors:

Git default branch is not set, see the documentation on setting a default branch.
Review of the 7.x-1.x branch (commit 9ab3c8b):

./global_logout.module: all functions should be prefixed with your module/theme name to avoid name clashes. See https://www.drupal.org/node/318#naming

function load_session_info($uid, $sid, $flag) {
Coder Sniffer has found some issues with your code (please check the Drupal coding standards). See attachment.
DrupalPractice has found some issues with your code, but could be false positives.
FILE: /var/www/drupal-7-pareview/pareview_temp/global_logout.module
---------------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
---------------------------------------------------------------------------
47 | WARNING | Unused variable $sql.
83 | WARNING | Unused variable $db_op.
93 | WARNING | Class name must be prefixed with the project name
| | "GlobalLogout"
302 | WARNING | Unused variable $user_info.
305 | WARNING | Unused variable $key.
---------------------------------------------------------------------------

FILE: ...ar/www/drupal-7-pareview/pareview_temp/global_logout_config.admin.inc
---------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------
18 | WARNING | All variables defined by your module must be prefixed with
| | your module's name to avoid name collisions with others.
| | Expected start with "global_logout" but found
| | "global_menu_name"
---------------------------------------------------------------------------

Time: 108ms; Memory: 8.75Mb

No automated test cases were found, did you consider writing Simpletests or PHPUnit tests? This is not a requirement but encouraged for professional software development.

Note that perfect adherence to Drupal Coding Standard is NOT a reason to block an application, except for total disregard of them. However, modules should follow them as closely as possible.

Manual Review

    Few observation :
  1. global_logout.module file at line no. 47
    $sql = "DELETE from {sessions} WHERE uid = " . $uid . ""; here sql variable not used anywhere in this fuction.
  2. Use more comments.
anishnirmal’s picture

Status: Needs work » Needs review
StatusFileSize
new5.56 KB

Thanks arunkumark, atul4drupal, and Rahul Seth.
Automated Review has been done.

anishnirmal’s picture

Title: Global Logout » [D7] Global Logout
PA robot’s picture

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

arkener’s picture

global_logout.install
Change the doc comment, it's currently the copied version of the admin menu module.
You might also want to add the following code to your globallogout_session_info schema for documentation purposes:

'foreign keys' => array(
  'globallogout_session_info_user' => array(
    'table' => 'users',
    'columns' => array('uid' => 'uid'),
  ),
),

global_logout.module
Move views hook implementations into seperate files. See hook_views_default_views and hook_views_data for more information.
Line 93: Place Global Logout Default inside a t().
Line 94: Place Global Logout Custom database table inside a t().
Line 145: Do not place parameters directly into the query. Please read the db_query documentation for more info.
Line 149: You might want to give the user the option to configure a date format.

anishnirmal’s picture

StatusFileSize
new6.07 KB

Thanks Arkener,
The changes and suggestions you have mentioned at #9 is done. The user is provided with an option at configuration page to customize the format.

TimRutherford’s picture

Status: Needs review » Needs work

Automated Review

Some issues detected by pareview.sh. Please fix these.

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
Yes: Does not cause module duplication and/or fragmentation.
Master Branch
No: Does not follow the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements.
3rd party assets/code
Yes: Follows the guidelines for 3rd party assets/code.
README.txt/README.md
No: Does not follow the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
Yes: Meets the security requirements.
Coding style & Drupal API usage
  1. (*) Readme is hard to read. Id split up the text into sections with clearly labelled section titles.
  2. (*) Default git branch is not set properly.
  3. Any reason the 'Active Logins' menu is placed with the main menu and not in the users account page? I think it would be cleaner and make much more sense there.

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.

This review uses the Project Application Review Template.

klausi’s picture

Status: Needs work » Needs review

The git branch and readme format are not application blockers, anything else that you found or should this be RTBC instead?

TimRutherford’s picture

Looking back at it, the 2 variables set in the settings form are never deleted on uninstall. But unless thats a blocker, I think its good to go.

anishnirmal’s picture

StatusFileSize
new6.24 KB

Hi TimRutherford,
Variables has been deleted on hook_uninstall and i have done some changes in readme.txt file too.

arvind.kinja’s picture

Add validation for time format field on Global logout setting page. Also add description for time format field and link to php.net so that user enter correct date.

anishnirmal’s picture

StatusFileSize
new6.57 KB

Thanks arvind.kinja,
Link for reference has been added and below a sample format is displayed respective of the format provided.

anishnirmal’s picture

StatusFileSize
new6.55 KB
arunkumark’s picture

Hi Anishnirmal,
Manual review Suggestions:
1. global_logout_user_logout() we can get user object from $account argument so no need load global variable($user).
2. Also in global_logout_user_login() the $account object have user details.
3. In function global_logout_load_session_info() please use return instead of using echo on line 150 and 153.

Thanks & Regards
Arunkumar K

anishnirmal’s picture

StatusFileSize
new6.56 KB

Thanks arun,
Changes have been modified. Can you please have a look at it.

pankajsachdeva’s picture

This module performs very well. It shows all the login sessions from all the browsers and it also log out successfully when access 'global/logout' menu.
One thing I want to mention that the 'Date' format of the config form not changeable. When I change it and save config, it changed to the same default format.
pankajsachdeva’s picture

Status: Needs review » Reviewed & tested by the community
heddn’s picture

Status: Reviewed & tested by the community » Fixed
    Readme mentions you need to flush cache. That happens automatically when enabling a module so it is an unnecessary step.
    What is BR_OS referring to? Ah, now I see, it refers to browser and operating system. I thought at first it was referring to the country of brazil. Maybe just spell out the full name?
    h5 nested directly below an h2 seems odd for your print out in the view.
    + Using php in your view is highly frowned upon. And I don't believe it is even necessary. You can use variable replacement.

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

I honestly hesitated a lot before marking this Fixed and granting git access on the last point. Please, please don't use php in views. However, the method in which it is being used isn't insecure and therefore not technical a security issue.

Thanks for your contribution, Anishnirmal!

I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.