close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Trouble Authenticate User Encryption Error?

Thread began 10/05/2009 10:26 pm by kathimccallum389750 | Last modified 10/14/2009 2:44 pm by Jason Byrnes | 1640 views | 5 replies |

kathimccallum389750

Trouble Authenticate User Encryption Error?

Today, I'm using WA for the first time. Started using the SA wizzard to create login pages - two different ways.

First without encryption - login works!

Second with encryption - Login page goes to a blank EmailPW.php page.

I've been reading the forums and tried:
- changing User Authentication
- checking database field names
- reconfiguring database password for encryption (not thru PHP script)
- checking session timeouts thru ISP using forum script - sessiontest.php


Stumped now - I'm giving some script to you. Sorry for the length. I'm not sure where to start. Hope you can help me.

Thanks in advance! Kathi


Login.php:
<?php require_once("../WA_SecurityAssist/WA_SHA1Encryption.php"); ?>
<?php require_once('../Connections/members.php');?>
<?php require_once( "../WA_SecurityAssist/Helper_PHP.php" ); ?>

<?php
if (isset($_POST["LogIn_x"]) && !isset($_POST["remembermeoption"])) {
setcookie("RememberMePWD", "", time()+(60*60*24*30), "/", "", 0);
}
?>
<?php
if (isset($_POST["LogIn_x"]) && !isset($_POST["remembermeoption"])) {
setcookie("RememberMeUN", "", time()+(60*60*24*30), "/", "", 0);
}
?>
<?php
if(isset($_POST["LogIn_x"])){
$WA_Auth_Parameter = array(
"connection" => $members,
"database" => $database_members,
"tableName" => "members",
"columns" => explode($WA_Auth_Separator,"UserEmail".$WA_Auth_Separator."UserPassword"),
"columnValues" => explode($WA_Auth_Separator,"".((isset($_POST["username"]))?$_POST["username"]:"") ."".$WA_Auth_Separator."".WA_SHA1Encryption(((isset($_POST["userpassword"]))?$_POST["userpassword"]:"")) .""),
"columnTypes" => explode($WA_Auth_Separator,"text".$WA_Auth_Separator."text"),
"sessionColumns" => explode($WA_Auth_Separator,"id"),
"sessionNames" => explode($WA_Auth_Separator,"id"),
"successRedirect" => "members_Profile.php",
"failRedirect" => "members_EmailPW.php",
"gotoPreviousURL" => TRUE,
"keepQueryString" => TRUE
);
WA_AuthenticateUser($WA_Auth_Parameter);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin




More...
____________________________________________________________________________
helper.php

<?php require_once( "HelperGroupsRulesPHP.php" ); ?>
<?php require_once( "Mail_PHP.php" ); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}

$WA_Auth_Separator = "|§|";

function WA_AuthenticateUser($WA_Auth_Parameter){

$UserAuthenticated = false;

mysql_select_db($WA_Auth_Parameter["database"], $WA_Auth_Parameter["connection"]);
$WA_Auth_loginSQL = "SELECT `".implode('`,`', $WA_Auth_Parameter["sessionColumns"])."` FROM `".$WA_Auth_Parameter["tableName"]."` WHERE ";

for($idx=0;$idx<count($WA_Auth_Parameter["columns"]);$idx++){
$WA_Auth_loginSQL = sprintf($WA_Auth_loginSQL.(($idx!=0)?" AND ":" ")."`%s`=%s ", $WA_Auth_Parameter["columns"][$idx], WA_GetSQLValueString($WA_Auth_Parameter["columnValues"][$idx], $WA_Auth_Parameter["columnTypes"][$idx]));
}
$WA_Auth_RS = mysql_query($WA_Auth_loginSQL, $WA_Auth_Parameter["connection"]) or die(mysql_error());
$WA_Auth_Rows = mysql_num_rows($WA_Auth_RS);

if($WA_Auth_Rows){
$UserAuthenticated = true;

$idx = 0;
foreach ($WA_Auth_Parameter["sessionNames"] as $sessionName){
$_SESSION[$sessionName] = mysql_result($WA_Auth_RS,0,$WA_Auth_Parameter["sessionColumns"][$idx]);
$idx++;
}

if (isset($_GET['accesscheck'])) {
$WA_Auth_Parameter["successRedirect"] = $_GET['accesscheck'];
}

if($WA_Auth_Parameter["successRedirect"]!=""){
$WA_Auth_Parameter["successRedirect"] = WA_Auth_BuildRedirectURL($WA_Auth_Parameter["successRedirect"], $WA_Auth_Parameter["keepQueryString"], FALSE);
header("Location: ".$WA_Auth_Parameter["successRedirect"]);
exit();
}
}

if($WA_Auth_Parameter["failRedirect"]!=""){
$WA_Auth_Parameter["failRedirect"] = WA_Auth_BuildRedirectURL($WA_Auth_Parameter["failRedirect"], $WA_Auth_Parameter["keepQueryString"], FALSE);
header("Location: ".$WA_Auth_Parameter["failRedirect"]);
exit();
}
}


function WA_Auth_ClearSession($clearAll, $clearThese){

if($clearAll){
foreach ($_SESSION as $key => $value){
unset($_SESSION[$key]);
}
}
else{
foreach($clearThese as $value){
unset($_SESSION[$value]);
}
}
}

function WA_Auth_RestrictAccess($redirectURL){
$redirectURL = WA_Auth_BuildRedirectURL($redirectURL, FALSE, TRUE);
header("Location: ".$redirectURL);
exit();
}

function WA_Auth_ForgotPassword($WA_Auth_Parameter){
$selectColumns = array();
for($idx=0;$idx<count($WA_Auth_Parameter["selectColumns"]);$idx++){
if($WA_Auth_Parameter["selectColumns"][$idx]!=''){
$selectColumns[] = $WA_Auth_Parameter["selectColumns"][$idx];
}
}
$selectColumns[] = $WA_Auth_Parameter["usernameColumn"];
$selectColumns[] = $WA_Auth_Parameter["passwordColumn"];
$selectColumns[] = $WA_Auth_Parameter["toAddressColumn"];


mysql_select_db($WA_Auth_Parameter["database"], $WA_Auth_Parameter["connection"]);
$WA_Auth_ForgotSQL = "SELECT `".implode('`,`', $selectColumns)."` FROM `".$WA_Auth_Parameter["tableName"]."` WHERE `".$WA_Auth_Parameter["filterColumn"]."` =";
$WA_Auth_ForgotSQL = sprintf($WA_Auth_ForgotSQL." %s ", WA_GetSQLValueString($WA_Auth_Parameter["columnValue"], $WA_Auth_Parameter["columnType"]));

$WA_Auth_RS = mysql_query($WA_Auth_ForgotSQL, $WA_Auth_Parameter["connection"]) or die(mysql_error());
$WA_Auth_Rows = mysql_num_rows($WA_Auth_RS);

if($WA_Auth_Rows){
$row_WA_Auth_RS = mysql_fetch_assoc($WA_Auth_RS);
$WA_Auth_Parameter["mailBody"] = preg_replace("/\\n/", "\r\n", $WA_Auth_Parameter["mailBody"]);

for($idx=0;$idx<count($selectColumns);$idx++){
$WA_Auth_Parameter["mailBody"] = preg_replace("/\[".$selectColumns[$idx]."\]/", $row_WA_Auth_RS[$selectColumns[$idx]], $WA_Auth_Parameter["mailBody"]);
}
for($idx=0;$idx<count($WA_Auth_Parameter["sessionVariables"]);$idx++){
$WA_Auth_Parameter["mailBody"] = preg_replace("/\[Session\.".$WA_Auth_Parameter["sessionVariables"][$idx]."\]/", isset($_SESSION[$WA_Auth_Parameter["sessionVariables"][$idx]])?$_SESSION[$WA_Auth_Parameter["sessionVariables"][$idx]]:"", $WA_Auth_Parameter["mailBody"]);
}
if($WA_Auth_Parameter["fromAddressDisplay"]!=''){
$WA_Auth_Parameter["fromAddress"] = $WA_Auth_Parameter["fromAddress"].'|WA|'.$WA_Auth_Parameter["fromAddressDisplay"];
}
$WA_Auth_Parameter["toAddress"] = $row_WA_Auth_RS[$WA_Auth_Parameter["toAddressColumn"]];
call_user_func($WA_Auth_Parameter["emailFunction"], $WA_Auth_Parameter);
if($WA_Auth_Parameter["successRedirect"]!=""){
$WA_Auth_Parameter["successRedirect"] = WA_Auth_BuildRedirectURL($WA_Auth_Parameter["successRedirect"], $WA_Auth_Parameter["keepQueryString"], FALSE);
header("Location: ".$WA_Auth_Parameter["successRedirect"]);
exit();
}

}
else{
if($WA_Auth_Parameter["failRedirect"]!=""){
$WA_Auth_Parameter["failRedirect"] = WA_Auth_BuildRedirectURL($WA_Auth_Parameter["failRedirect"], $WA_Auth_Parameter["keepQueryString"], FALSE);
header("Location: ".$WA_Auth_Parameter["failRedirect"]);
exit();
}
}
}


function WA_Auth_BuildRedirectURL($redirectURL, $keepCurrentQueryString, $addDeniedURL){

if ($keepCurrentQueryString && $redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "") {
$redirectURL .= ((strpos($redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}

if($addDeniedURL){
$WA_Auth_Referrer = $_SERVER['PHP_SELF'];
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0){
$WA_Auth_Referrer .= "?".$QUERY_STRING;
}
$redirectURL = $redirectURL.((strpos($redirectURL, "?"))?"&":"?")."accesscheck=".urlencode($WA_Auth_Referrer);
}
if(strpos($redirectURL, '/') === 0){
$redirectURL = 'http'.(($_SERVER["HTTPS"] && $_SERVER["HTTPS"]!="off")?"s":"").'://'.$_SERVER['HTTP_HOST'].$redirectURL;
}

return $redirectURL;
}

// Rules functions

function WA_Auth_RulePasses($ruleName){
return WA_Auth_RuleObject_EvaluateRules($ruleName);
}

function WA_Auth_RuleObject_EvaluateRules($ruleName){
$rulePasses = FALSE;
$comparisons = WA_Auth_GetComparisonsForRule($ruleName);
$compareLen = count($comparisons);

for($idx=0;$idx<$compareLen;$idx++){
$compareSucceeds = FALSE;
$comparison = $comparisons[$idx];
switch($comparison[2]) {
/*
1-9 Direct value comparisons
10-19 String Comparisons
20-29 List Comparisons
*/
case 1:
$compareSucceeds = ($comparison[1]==$comparison[3]);
break;

case 2:
$compareSucceeds = ($comparison[1]!=$comparison[3]);
break;

case 3:
$compareSucceeds = ($comparison[1]<$comparison[3]);
break;

case 4:
$compareSucceeds = ($comparison[1]<=$comparison[3]);
break;

case 5:
$compareSucceeds = ($comparison[1]>$comparison[3]);
break;

case 6:
$compareSucceeds = ($comparison[1]>=$comparison[3]);
break;

case 20:
$compareSucceeds = WA_Auth_GroupContainsValue($comparison[3], $comparison[1]);
break;


?>

Sign in to reply to this post

Jason ByrnesWebAssist

Are you testing logging in with Password Encryption using an existing registration that was created before modifying the registration page to store the password encrypted? Or have you created a New User that you are testing?

For the logging to succeed, the password must be stored in the database in the SHA1 encrypted format.

I can see from the code you supplied that the login page has been modified for Password Encryption so here are the other things to check:

1) make sure the password column in the database is set to hold 40 characters. The SHA1 encrypted password will be 40 characters long.

2) have you modified the registration page as outlined in the tutorial? On the registration page, the Dreamweaver Insert Record behavior needs to be replaced with the DataAssist insert record behavior so that the password will be stored in the DB in SHA1 format.

3) once the registration page has been modified for SHA1 encryption, you need to register a new user. Any user created before modifying the registration page will no longer function.

Sign in to reply to this post

kathimccallum389750

Changes in authentication errors

Jason -

Thanks for your help. I can see several mistakes in my code now.

The site locked out the members and I was unable to fix the login. I removed all php actions/code from the files. In doing this, I realized authentication was occurring in previous files stored in a folder 'old'. Also, there were duplicate actions in several files. The helper, groups, connections and config are new to me, so I couldn't trace the code.

After removing all WA code from all the files, my site visitors can view the pages. Yaa!

I would like to start from scratch. The first pages I created using SA wizzard worked great until I started changing authentication. Maybe re-install WA?

What do you suggest? Thanks in advance!

Kathi

______________________________________________________________________

I would like to start from scratch. My first How do I remove all WA coded files and from the site and start over.

Sign in to reply to this post

Jason ByrnesWebAssist

go to modify Security Assist -> Access Pages manager and remove the access rules you have applied to any of the site pages.

Delete the WA_SecurityAssist and WA_DataAssist folders from your site.

Delete the pages created by the Securituy Assist wizard.

This should get you back to the beginning.

Sign in to reply to this post

kathimccallum389750

Starting Over - Deleting Files Created by SA

Hello -

I'm going to delete the files created by SA.

Is it necessary to delete folder WA_SecurityAssist and SpryAssets?

Thanks in advance - Kathi

Sign in to reply to this post

Jason ByrnesWebAssist

it is not necessary to delete the spry assets folder, but you should delete the security assist folder to remove any of the rules you created.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...