CMS MADE SIMPLE FORGE

CMS Made Simple Core

 

[#11269] Admin login twice

avatar
Created By: Deleted User (deleteduser_11200)
Date Submitted: Sat Jan 14 15:39:59 -0500 2017

Assigned To:
Version: 2.1.6
CMSMS Version: 2.1.6
Severity: None
Resolution: None
State: Closed
Summary:
Admin login twice
Detailed Description:
* Problem:

Currently I am updating some CMSMS v1 sites to CMSMS v2 with SSL (https://). 
On one site running CMSMS v2.1.6 I got problems with logging in to the /admin
area.

The first login attempt succeeds but is redirected back to the
https://hostname.tld/admin/login.php

forum reference: https://forum.cmsmadesimple.org/viewtopic.php?f=8&t=75734 

* Investigation:

By verifying all my config.php settings, the Apache/2.4.7 (Ubuntu) + Lets
Encrypt SSL server configuration I did not find something uncommon or strange.
On an other CMSMS v2.1.5 site with the exact same settings the /admin login
works as expected. After a succesful login the user is redirected to:
/admin/index.php?_sk_=XXc4bXXXaXXXXeXe

The CMSMS 2.1.5 site is an e-commerce website with alle the common CMSMS +
CGEcommerce modules.
The CMSMS 2.1.6 site runs vanilla CMSMS with some LISE instances 

By looking at the HTTP Headers from the 2.1.6 site I have to login twice I see
that the cookies and session information is stored ok on the first attempt:

Request URL:https://hostname.tld/admin/login.php
Request Method:POST
Status Code:302 Found
Location:https://hostname.tld/admin/login.php
Pragma:no-cache
Server:Apache/2.4.7 (Ubuntu)
Set-Cookie:_sk_=XXc4bXXXaXXXXeXe; path=/; domain=hostname.tld; secure; httponly
Set-Cookie:cms_passhash=XXc4bXXXaXXXXeXeXXc4bXXXaXXXXeXeXXc4bXXXaXXXXeXe;
path=/; domain=hostname.tld; secure; httponly
Set-Cookie:cms_admin_user_id=1; path=/; domain=hostname.tld; secure; httponly

* Unfriendly solution:

After the first login the enduser can type in: https://hostname.tld/admin/ in
the browser to start working with the CMS.

Or he/she has to login for the second time with the same credentials.

Ad1) The News Modules is set as the homepage on: My Preferences -> My Account ->
[User Preferences] : Homepage

After the second login I see this:
https://hostname.tld/admin/moduleinterface.php?mact=News,m1_,defaultadmin,0&_CMSKEY_=XXXXXXXXXXXXXXXX&_sk_=c3bc86b6527b2a00

!! The login is correct but has a weird CMSKEY: "CMSKEY_=XXXXXXXXXXXXXXXX"

* My config.php settings:

$config['url_rewriting'] = 'mod_rewrite';
$config['page_extension'] = '/';
$config['root_url'] = 'https://hostname.tld';
$config['admin_url'] = 'https://hostname.tld/admin';

* A temporary tweak:

To give help my enduser overcome a double login hassle I tweaked login.php a
tiny bit like:

 19 #$Id: login.php 10858 2016-10-03 17:03:35Z calguy1000 $

238     // attempt to redirect to the originally requested page
239     $tmp = $_SESSION["redirect_url"];
240     unset($_SESSION["redirect_url"]);
241 
242     if( strstr($tmp,CMS_SECURE_PARAM_NAME.'=') !== FALSE ) {
243       $the_url = new cms_url($tmp);
244       $the_url->set_queryvar(CMS_SECURE_PARAM_NAME,$_SESSION[CMS_USER_KEY]);
245       $tmp = (string)$the_url;
246     }
247 
248     if( !strstr($tmp,'.php') || endswith($tmp,'/') ) {
249       // force the url to go to index.php
250       $tmp =
$config['admin_url'].'/index.php?'.CMS_SECURE_PARAM_NAME.'='.$_SESSION[CMS_USER_KEY];
251     }
252 
253     //redirect($tmp);
254     redirect($config['admin_url']);


History

Comments
avatar
Date: 2017-01-16 07:43
Posted By: Deleted User (deleteduser_11200)

Guys I close this issue.  

In my installation there was still an old  1.xx module that was not ported to
CMSMS v2 correctly.

// In the ModuleName.module.php the deprecated SetParameters method still
existed:

https://apidoc.cmsmadesimple.org/classes/CMSModule.html#method_SetParameters

I added the InitializeAdmin and InitializeFrontEnd method and all login troubles
disappeared.


* A general advise for other CMSMS users:

If you face the double login / twice login problem. 
Rename the non core CMSMS modules  in your /modules/* folder to something like:
XXX_Module and logout / login again. If you can login as normal something is
wrong with your third party or custom modle.

Debuging modules on your dev environment with (php.ini)  error_reporting on 
might also help. Although class.CMSModule.php still has:   function
SetParameters() {} so it is called without warning you.
      
Updates

Updated: 2017-01-16 07:43
summary: Admnin login twice => Admin login twice
resolution_id: => 5
state: Open => Closed