close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Name of variable / response generated when a user tries to log in

Thread began 4/23/2015 12:12 pm by iain331081 | Last modified 4/24/2015 12:12 pm by Ray Borduin | 3595 views | 12 replies |

iain331081

Name of variable / response generated when a user tries to log in

This is a bit of a random one, but I have been looking at creating an app where users can register and login using the same database backend that exists for a website. I have the registration working where a new record is successfully created in the DB when someone registers in the app.

But I haven't quite got the login to work - I'm using some JS request to grab the response of the login check - am I right in thinking if the login is successful the response to look for would be 'Log in success'?

I'm just getting that from the line:

<?php if(WA_Auth_RulePasses("Log in success")){ // Begin Show Region ?>

in the login page.

Hope that makes some sense, and I'm barking up the right tree, although its confused further by some reference to JSON which I'm not really familiar with, and don't think there is any JSON on the log in web page.

Thanks for any pointers - but I think all I need to confirm is the correct value of any response for a successful login.

Sign in to reply to this post

iain331081

More info below.

Sign in to reply to this post

Ray BorduinWebAssist

This page won't have a response on success or failure. You would have to check the webassist/security_assist/helpergroupsrulesphp.php file to see the correct rule name to use, but probably you would remove all of this from the bottom of the page:

php:
<?php if(WA_Auth_RulePasses("Validated form")){ // Begin Show Region ?>

<p><span class="loginfail">Invalid username or password - please try again.</span></p>
<?php // End Show Region ?>

<?php if(WA_Auth_RulePasses("Log in success")){ // Begin Show Region ?>
<p>You have been logged in</p>
<?php // End Show Region ?>

<?php if(WA_Auth_RulePasses("Failed log in")){ // Begin Show Region ?>
<p><span class="loginfail">Invalid username or password - please try again.</span></p>
<?php // End Show Region ?>

<?php if(WA_Auth_RulePasses("Emailed Password")){ // Begin Show Region ?>
<p>Password information emailed, please check your inbox</p>
<?php // End Show Region ?>

<?php if(WA_Auth_RulePasses("Successful update")){ // Begin Show Region ?>
<p>Registration completed successfully, please log in to access the site</p>
<?php // End Show Region ?>



and instead add something like:


php:
<?php if(WA_Auth_RulePasses("Logged In To trade_users_app_temp")){ // Begin Show Region ?>Log in success<?php // End Show Region ?>
Sign in to reply to this post
Did this help? Tips are appreciated...

iain331081

Thanks Ray - to be honest all of that can probably go from that page - it's only still there for my reference.

All I really know is that the http request back in the app needs some response from the web server to let it know whether the login was successful or not. Will have a look in that other helpergroupsrulesrulesphp.php file, but I might come back to you.

Sign in to reply to this post

iain331081

OK - looking in there there are two rules - logged in, and logged in to trade_users. (I can use the original trade_users table to test logging in.)

They look like:

php:
<?php

case "Log in success":
            
$comparisons[0] = array(TRUE"".((isset($_GET['loggedIn']))?$_GET['loggedIn']:"")  .""2"");
            break;
?>



and

php:
<?php

case "Logged in to trade_users":
            
$comparisons[0] = array(TRUE"".((isset($_SESSION['SecurityAssist_UserID']))?$_SESSION['SecurityAssist_UserID']:"")  .""2"");
            break;
?>



But not sure what or how to pass anything back to the app side.

Sign in to reply to this post

Ray BorduinWebAssist

Putting this on the page should do it:


php:
<?php if(WA_Auth_RulePasses("Logged in to trade_users")){ // Begin Show Region ?>Log in success<?php // End Show Region ?>



This will return the text between the begin and end region code.

Just make sure you don't have any blank lines in your code and it should work with your app code above.

Sign in to reply to this post
Did this help? Tips are appreciated...

iain331081

Thanks Ray - can't seem to get it to work.

So on the app side I have a login form with two text fields, UsernameInput and PasswordInput in this JS expression:

var Log_In_group_Username = UsernameInput
var Log_In_group_Password = PasswordInput
var result = Request.post('http://www.miradatravelmedia.com/GSG_App/login.php', { Log_In_group_Username: Log_In_group_Username, Log_In_group_Password: Log_In_group_Password })
function done(response) {
if (response === 'Log in success') {
Event.trigger('loginSuccess');
} else {
Event.trigger('loginFail');
}
}

So that should be passing the entered values to login.php on the web server.

And WA PHP in that login.php page below:

Sign in to reply to this post

Ray BorduinWebAssist

Looks like it would be right to me.

What if you just add: <?php echo("Log in success"); ?>

That would presumably bypass the login and respond as if everyone successfully logged in. That could help you narrow down whether it is an issue with the app or the web page.

Sign in to reply to this post
Did this help? Tips are appreciated...

iain331081

Thanks Ray - that makes sense. I added that and nothing is happening on the app side.

So I guess that suggests the issue is with the JS on the app side.

I get that:

Request.post("http://www.miradatravelmedia.com/GSG_App/login.php", { Log_In_group_Username: Log_In_group_Username, Log_In_group_Password: Log_In_group_Password })

Should send the variables:

var Log_In_group_Username = UsernameInput
var Log_In_group_Password = PasswordInput

to the web server.

And they should be picked up in the line:

php:
<?php

"columnValues" => explode($WA_Auth_Separator,"".((isset($_POST["Log_In_group_Username"]))?$_POST["Log_In_group_Username"]:"")  ."".$WA_Auth_Separator."".((isset($_POST["Log_In_group_Password"]))?$_POST["Log_In_group_Password"]:"")  .""), ?php>



And I follow that

if (response === 'Log in success') {
Event.trigger('loginSuccess');
} else {
Event.trigger('loginFail');
}

Should pick up whatever is output on the web server and then do one of two things, depending in what it is.

But not so sure what the var result = is doing?

Sign in to reply to this post

Ray BorduinWebAssist

I'm not sure how it is supposed to know to call the done function... Is this just regular javascript trying to use AJAX? I'm pretty sure your php page is good now. It is now a matter of debugging your app code.

Keep the echo statement outside of any IF statements and you will know the issue isn't with what form elements or values are being posted it is simply getting the result from the page.

Sign in to reply to this post
Did this help? Tips are appreciated...
loading

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...