userfrosting / UserFrosting

Modern PHP user login and management framework
https://www.userfrosting.com
Other
1.63k stars 366 forks source link

Registration Page not Registering #281

Closed jwren5 closed 9 years ago

jwren5 commented 9 years ago

I have added several fields to the registration page, but even using the original code, there seems to be an issue with the registration.

The validation seems to be working and all the icons turn green upon the clicking of the submit button, however it will not create a user.

There was another issue thread that mentioned this same issue and they resolved it through their hosting provider. I contacted mine and mentioned that it may be a Mod_security issue and they informed me they are a Windows server and this is not supported so it cannot be an issue. That the issue is within the code.

Is this the case? Can you help? I haven't changed any code that would prohibit this from happening.

Thanks in advance!

alexweissman commented 9 years ago

Do you get any messages in your browser console?

jwren5 commented 9 years ago

No. I fill out the form, click submit, and all the icons turn green. No user is created at all within the system or the database afterward. No error message.

On Sat, Mar 28, 2015 at 6:51 PM, Alex Weissman notifications@github.com wrote:

Do you get any messages in your browser console?

— Reply to this email directly or view it on GitHub https://github.com/alexweissman/UserFrosting/issues/281#issuecomment-87335540 .

alexweissman commented 9 years ago

Sorry, I meant in the brower's Javascript console. This can be accessed from "Tools->Web Developer" menu in Firefox, or "More tools->Javascript Console" in Chrome. For help with other browsers, please Google "where is the javascript console in ____".

jwren5 commented 9 years ago

The console is displaying these errors.

[Log] validating field: user_name='swren' (userfrosting.js, line 249) [Log] validating field: display_name='Sara' (userfrosting.js, line 249) [Log] validating field: email='jon@wrendesigned.com' (userfrosting.js, line 249) [Log] validating field: Full_Name='Sara Wren' (userfrosting.js, line 249) [Log] validating field: password='password' (userfrosting.js, line 249) [Log] validating field: passwordc='password' (userfrosting.js, line 249) [Log] validating field: captcha='35fb1' (userfrosting.js, line 249) [Error] Failed to load resource: the server responded with a status of 500 (Internal Server Error) (create_user.php, line 0) [Error] Failed to load resource: the server responded with a status of 404 (Not Found) (jquery.min.map, line 0)

On Mar 28, 2015, at 11:12 PM, Alex Weissman notifications@github.com wrote:

Sorry, I meant in the brower's Javascript console. This can be accessed from "Tools->Web Developer" menu in Firefox, or "More tools->Javascript Console" in Chrome. For help with other browsers, please Google "where is the javascript console in ____".

— Reply to this email directly or view it on GitHub https://github.com/alexweissman/UserFrosting/issues/281#issuecomment-87359378.

alexweissman commented 9 years ago

OK, so the problem is happening when the data gets POSTed to create_user.php. What about your PHP error log? Any messages there?

jwren5 commented 9 years ago

I don’t know if I have set up the PHP error log correctly.. I have been attempting to make that work several times. It doesn’t have anything in the log currently.

From researching online, it told me to create a php.ini file and put it in my root directory and add the following code: ;;; php error handling for production servers display_startup_errors = off display_errors = off html_errors = off log_errors = on docref_root = 0 docref_ext = 0 error_log = /error/php_error.log

enable subdirectory inheritance of custom php settings

suPHP_ConfigPath /home/path/public_html

deny access to php.ini

order allow,deny deny from all satisfy all

deny access to php error log

order allow,deny deny from all satisfy all

;;; general directive for setting php error level error_reporting = 8191

and then add a php_error.log file in a error folder. Is that anywhere remotely correct? I apologize for my lack of knowledge. I have been learning and learning, but this is one area where there is not much help online!

Thanks

Jon

On Mar 31, 2015, at 6:00 PM, Alex Weissman notifications@github.com wrote:

OK, so the problem is happening when the data gets POSTed to create_user.php. What about your PHP error log? Any messages there?

— Reply to this email directly or view it on GitHub https://github.com/alexweissman/UserFrosting/issues/281#issuecomment-88288781.

ghisi commented 9 years ago

Having the same issue here. In my case it looks like a permission issue, as I can see a 403 forbidden message in the console:

Forbidden

You don't have permission to access /uf/api/create_user.php on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

alexweissman commented 9 years ago

Most web servers have a pre-configured PHP error log. What server/platform are you using?

jwren5 commented 9 years ago

Its a shared hosting system through Arvixe and its a windows based server.

On Apr 1, 2015, at 7:36 AM, Alex Weissman notifications@github.com wrote:

Most web servers have a pre-configured PHP error log. What server/platform are you using?

— Reply to this email directly or view it on GitHub https://github.com/alexweissman/UserFrosting/issues/281#issuecomment-88483141.

alexweissman commented 9 years ago

On shared hosting, it's most likely writing errors to an error_log file in the directory in which they occur. Do you see any such file in the api directory?

jwren5 commented 9 years ago

there is a log file that says stuff like this

2015-04-01 02:45:34 W3SVC2481 grass 23.91.118.8 POST /api/create_user.php - 80 - 67.60.251.103 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10_10_2)+AppleWebKit/600.4.10+(KHTML,+like+Gecko)+Version/8.0.4+Safari/600.4.10 http://payment.wrendesignedhosting.com/register.php payment.wrendesignedhosting.com 500 0 0 309 809 109 2015-04-01 03:05:19 W3SVC2481 grass 23.91.118.8 POST /api/create_user.php - 80 - 67.60.251.103 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10_10_2)+AppleWebKit/600.4.10+(KHTML,+like+Gecko)+Version/8.0.4+Safari/600.4.10 http://payment.wrendesignedhosting.com/register.php payment.wrendesignedhosting.com 500 0 0 309 809 234

other than that, that is all I can find nothing in the api folder

On Apr 1, 2015, at 3:03 PM, Alex Weissman notifications@github.com wrote:

On shared hosting, it's most likely writing errors to an error_log file in the directory in which they occur. Do you see any such file in the api directory?

— Reply to this email directly or view it on GitHub https://github.com/alexweissman/UserFrosting/issues/281#issuecomment-88631421.

alexweissman commented 9 years ago

You might need to enable error logging in cpanel. See this thread: https://support.arvixe.com/index.php?/Knowledgebase/Article/View/136/10/my-website-shows-500-internal-server-error-intermittently

Otherwise, I would just contact them, or open an issue on their knowledgebase. It's really, really good to know how to access your php error log, beyond just the scope of solving this particular issue.

jwren5 commented 9 years ago

I appreciate your kindness. There is a spot to add a custom error, i have IIS, ASP.NET http://asp.net/, and ASP errors being shown detailed in browser. There is then a spot to add custom error with status, code (404, 404.0, etc), a response mode (file), and then path. would this be it?

On Apr 1, 2015, at 7:54 PM, Alex Weissman notifications@github.com wrote:

You might need to enable error logging in cpanel. See this thread: https://support.arvixe.com/index.php?/Knowledgebase/Article/View/136/10/my-website-shows-500-internal-server-error-intermittently https://support.arvixe.com/index.php?/Knowledgebase/Article/View/136/10/my-website-shows-500-internal-server-error-intermittently Otherwise, I would just contact them, or open an issue on their knowledgebase. It's really, really good to know how to access your php error log, beyond just the scope of solving this particular issue.

— Reply to this email directly or view it on GitHub https://github.com/alexweissman/UserFrosting/issues/281#issuecomment-88688574.

alexweissman commented 9 years ago

Can you post a screenshot?

jwren5 commented 9 years ago

thank you for your patience. I have finally got the error log (it was the hosting companies fault and they corrected the issue)

this is what the log says

[02-Apr-2015 21:06:48 America/Los_Angeles] Error (2): Missing argument 14 for createUser(), called in E:\HostingSpaces\wrenjon\ payment.wrendesignedhosting.com\wwwroot\api\create_user.php on line 109 and defined in E:\HostingSpaces\wrenjon\payment.wrendesignedhosting.com\wwwroot\models\secure_functions.php on line 73 [02-Apr-2015 21:06:48 America/Los_Angeles] PHP Fatal error: Uncaught exception 'ErrorException' with message 'Missing argument 14 for createUser(), called in E:\HostingSpaces\wrenjon\ payment.wrendesignedhosting.com\wwwroot\api\create_user.php on line 109 and defined' in E:\HostingSpaces\wrenjon\payment.wrendesignedhosting.com \wwwroot\models\secure_functions.php:73 Stack trace:

0 E:\HostingSpaces\wrenjon\payment.wrendesignedhosting.com\wwwroot\models\secure_functions.php(73):

logAllErrors(2, 'Missing argumen...', 'E:\HostingSpace...', 73, Array)

1 E:\HostingSpaces\wrenjon\payment.wrendesignedhosting.com\wwwroot\api\create_user.php(109):

createUser('jwren6', 'Jon', 'jwren@nnu.edu', 'jon wren', '511 s elder st', 'nampa', 'id', '83686', 'New Member', 'password', 'password', '0', NULL)

2 {main}

thrown in E:\HostingSpaces\wrenjon\payment.wrendesignedhosting.com\wwwroot\models\secure_functions.php on line 73

thoughts?

Jon

On Thu, Apr 2, 2015 at 10:23 AM, Jon WrenDesigned jon@wrendesigned.com wrote:

On Apr 2, 2015, at 10:18 AM, Alex Weissman notifications@github.com wrote:

Can you post a screenshot?

— Reply to this email directly or view it on GitHub https://github.com/alexweissman/UserFrosting/issues/281#issuecomment-88963919 .

alexweissman commented 9 years ago

Yup, so you appear to be missing a function argument in your call to createUser.

jwren5 commented 9 years ago

this is that line (108-113)

 // Try to create the new user
if ($new_user_id = createUser($user_name, $display_name, $password, $passwordc, $email, $Full_Name, $Address, $City, $State, $Zip_Code, $title, $require_activation, $admin)){

} else {
    apiReturnError($ajax, ($admin == "true") ? ACCOUNT_ROOT : SITE_ROOT);
}

On Apr 3, 2015, at 8:58 AM, Alex Weissman notifications@github.com wrote:

Yup, so you appear to be missing a function argument in your call to createUser.

— Reply to this email directly or view it on GitHub https://github.com/alexweissman/UserFrosting/issues/281#issuecomment-89311975.

alexweissman commented 9 years ago

Can I see you modified createUser function?

jwren5 commented 9 years ago

you bet. from the secure_functions.php

function createUser($user_name, $display_name, $email, $Full_Name, $Address, $Address_Line_2, $City, $State, $Zip_Code, $title, $password, $passwordc, $require_activation, $admin) { // if we're in admin mode, then the user must be logged in and have appropriate permissions if ($admin == "true"){ // This block automatically checks this action against the permissions database before running. if (!checkActionPermissionSelf(FUNCTION, func_get_args())) { addAlert("danger", "Sorry, you do not have permission to access this resource."); return false; } }

$error_count = 0;

// Check values
if(minMaxRange(1,25,$user_name))
{
    addAlert("danger", lang("ACCOUNT_USER_CHAR_LIMIT",array(1,25)));
    $error_count++;
}
if(!ctype_alnum($user_name)){
    addAlert("danger", lang("ACCOUNT_USER_INVALID_CHARACTERS"));
    $error_count++;
}
if(minMaxRange(1,50,$display_name))
{
    addAlert("danger", lang("ACCOUNT_DISPLAY_CHAR_LIMIT",array(1,50)));
    $error_count++;
}
if(!isValidName($display_name)){
    addAlert("danger", lang("ACCOUNT_DISPLAY_INVALID_CHARACTERS"));
    $error_count++;
}
if(!isValidEmail($email))
{
    addAlert("danger", lang("ACCOUNT_INVALID_EMAIL"));
    $error_count++;
}
 if(minMaxRange(1,100,$Full_Name))
{
    addAlert("danger", "Name must be between 1 and 100 characters long!");
    $error_count++;
}
 if(minMaxRange(1,100,$Address))
{
    addAlert("danger", "Address must be between 1 and 100 characters long!");
    $error_count++;
}
 if(minMaxRange(1,100,$City))
{
    addAlert("danger", "City must be between 1 and 100 characters long!");
    $error_count++;
}
 if(minMaxRange(1,2,$State))
{
    addAlert("danger", "Please use a valid postal code!");
    $error_count++;
}
 if(minMaxRange(1,10,$Zip_Code))
{
    addAlert("danger", "Zip Code must be between 1 and 10 characters long!");
    $error_count++;
}

if(minMaxRange(1,150,$title)) {
    addAlert("danger", lang("ACCOUNT_TITLE_CHAR_LIMIT",array(1,150)));
    $error_count++;
}
if(minMaxRange(8,50,$password) && minMaxRange(8,50,$passwordc))
{
    addAlert("danger", lang("ACCOUNT_PASS_CHAR_LIMIT",array(8,50)));
    $error_count++;
}
else if($password != $passwordc)
{
    addAlert("danger", lang("ACCOUNT_PASS_MISMATCH"));
    $error_count++;
}

if(usernameExists($user_name)) {
    addAlert("danger", lang("ACCOUNT_USERNAME_IN_USE",array($user_name)));
    $error_count++;
}
if(displayNameExists($display_name)) {
    addAlert("danger", lang("ACCOUNT_DISPLAYNAME_IN_USE",array($display_name)));
    $error_count++;
}
if(emailExists($email)) {
    addAlert("danger", lang("ACCOUNT_EMAIL_IN_USE",array($email)));
    $error_count++;
}

//Construct a secure hash for the plain text password
$password_hash = passwordHashUF($password);
if ($password_hash === null){
    addAlert("danger", lang("PASSWORD_HASH_FAILED"));
    $error_count++;        
}

// Exit on any invalid parameters
if($error_count != 0)
    return false;

//Construct a unique activation token (even if activation is not required)
$activation_token = generateActivationToken();
$active = 1;

//Do we need to require that the user activate their account first?
if($require_activation) {

    //User must activate their account first
    $active = 0;

    $mailSender = new userCakeMail();

    //Build the activation message
    $activation_message = lang("ACCOUNT_ACTIVATION_MESSAGE",array(SITE_ROOT . "api/", $activation_token));

    //Define more if you want to build larger structures
    $hooks = array(
        "searchStrs" => array("#ACTIVATION-MESSAGE","#ACTIVATION-KEY","#USERNAME#"),
        "subjectStrs" => array($activation_message,$activation_token,$display_name)
    );

    /* Build the template - Optional, you can just use the sendMail function
    Instead to pass a message. */
    // If there is a mail failure, fatal error
    if(!$mailSender->newTemplateMsg("new-registration.txt",$hooks)) {
        addAlert("danger", lang("MAIL_ERROR"));
        return false;
    } else {
        //Send the mail. Specify users email here and subject.
        //SendMail can have a third paremeter for message if you do not wish to build a template.
        if(!$mailSender->sendMail($email, "Please activate your account")) {
            addAlert("danger", lang("MAIL_ERROR"));
            return false;
        }
    }
}

// Insert the user into the database and return the new user's id
return addUser($user_name, $display_name, $title, $password_hash, $email, $active, $activation_token, $Full_Name, $Address, $City, $State, $Zip_Code);

}

On Apr 3, 2015, at 9:36 AM, Alex Weissman notifications@github.com wrote:

Can I see you modified createUser function?

— Reply to this email directly or view it on GitHub https://github.com/alexweissman/UserFrosting/issues/281#issuecomment-89327527.

alexweissman commented 9 years ago

Ok, so you have a function: function createUser($user_name, $display_name, $email, $Full_Name, $Address, $Address_Line_2, $City, $State, $Zip_Code, $title, $password, $passwordc, $require_activation, $admin) {

And you are calling it via: createUser($user_name, $display_name, $password, $passwordc, $email, $Full_Name, $Address, $City, $State, $Zip_Code, $title, $require_activation, $admin)

This should make the problem pretty clear at this point...

jwren5 commented 9 years ago

its always the simple stuff.. thank you! that did it.

On Apr 3, 2015, at 10:10 AM, Alex Weissman notifications@github.com wrote:

Ok, so you have a function: function createUser($user_name, $display_name, $email, $Full_Name, $Address, $Address_Line_2, $City, $State, $Zip_Code, $title, $password, $passwordc, $require_activation, $admin) {

And you are calling it via: createUser($user_name, $display_name, $password, $passwordc, $email, $Full_Name, $Address, $City, $State, $Zip_Code, $title, $require_activation, $admin)

This should make the problem pretty clear at this point...

— Reply to this email directly or view it on GitHub https://github.com/alexweissman/UserFrosting/issues/281#issuecomment-89339125.

alexweissman commented 9 years ago

Let me know if you have any more problems!