0
@@ -22,10 +22,6 @@ $CMS_ADMIN_PAGE=1;
0
require_once('../include.php');
0
if (isset($_SESSION['logout_user_now']))
0
unset($_SESSION['login_user_username']);
0
@@ -40,129 +36,11 @@ if (isset($_POST['logincancel']))
0
//redirect(CmsConfig::get('root_url') . '/index.php', true);
0
-$openid_enabled = CmsOpenid::is_enabled();
0
- if ((isset($_REQUEST['openid_mode']) && $_REQUEST['openid_mode'] == 'id_res') || (isset($_REQUEST['openid.mode']) && $_REQUEST['openid.mode'] == 'id_res'))
0
- #See if the openid matches
0
- if (CmsOpenid::check_authentication($_REQUEST))
0
- #Now see if the checksum actually is for a user
0
- $user = cms_orm()->user->find_by_checksum($_REQUEST['checksum']);
0
- #Put in a new checksum so the return url from provider can't be reused
0
- $checksum = CmsOpenid::generate_checksum();
0
- $user->checksum = $checksum;
0
- if (CmsLogin::login_by_id($user->id))
0
- if (isset($_SESSION['redirect_url']))
0
- $tmp = $_SESSION['redirect_url'];
0
- unset($_SESSION['redirect_url']);
0
- CmsResponse::redirect($tmp);
0
- redirect(CmsConfig::get('root_url') . '/' . CmsConfig::get('admin_dir') . '/index.php', true);
0
- $error .= lang('authenticationfailed 3');
0
- $error .= lang('authenticationfailed 2');
0
- $error .= lang('authenticationfailed 1');
0
+$redirect_url = CmsConfig::get('root_url') . '/' . CmsConfig::get('admin_dir') . '/index.php';
0
-if (isset($_POST['username'])) $username = CmsRequest::clean_value($_POST['username']);
0
-if (isset($_POST['openid'])) $openid = CmsRequest::clean_value($_POST['openid']);
0
-if (isset($_POST['username']) && isset($_POST['password'])) {
0
- if (isset($_POST['password'])) $password = $_POST['password'];
0
- if ($openid != '' && isset($_POST['loginsubmit']) && $openid_enabled)
0
- #Cleanup the open id and find a user so we can set the checksum
0
- $clean_openid = CmsOpenid::cleanup_openid($openid);
0
- $user = cms_orm()->user->find_by_openid($clean_openid);
0
- $obj = new CmsOpenid();
0
- if ($obj->find_server(CmsOpenid::create_url($openid)))
0
- #Make up a checksum and save it to the user
0
- $checksum = CmsOpenid::generate_checksum();
0
- $user->checksum = $checksum;
0
- #All should be good. Time to redirect out to the provider.
0
- $obj->do_authentication(CmsConfig::get('root_url') . '/' . CmsConfig::get('admin_dir') . '/login.php', $checksum);
0
- $error .= lang('usernameincorrect');
0
- else if ($username != '' && $password != '' && isset($_POST['loginsubmit']))
0
- if (CmsLogin::login($username, $password))
0
- // redirect to upgrade if db_schema it's old
0
- $current_version = $CMS_SCHEMA_VERSION;
0
- $query = 'SELECT version from '.cms_db_prefix().'version';
0
- $row = cms_db()->GetRow($query);
0
- if ($row) $current_version = $row['version'];
0
- if ($current_version < $CMS_SCHEMA_VERSION)
0
- CmsResponse::redirect(CmsConfig::get('root_url') . '/install/upgrade.php');
0
- // end of version check
0
- if (isset($_SESSION['redirect_url']))
0
- $tmp = $_SESSION['redirect_url'];
0
- unset($_SESSION['redirect_url']);
0
- CmsResponse::redirect($tmp);
0
- redirect(CmsConfig::get('root_url') . '/' . CmsConfig::get('admin_dir') . '/index.php', true);
0
- $error .= lang('usernameincorrect');
0
- $error .= lang('usernameincorrect');
0
+CmsLogin::handle_login_request($redirect_url, $username, $openid, $error, true);
0
CmsAdminTheme::start(true);
Comments
No one has commented yet.