Implementing user logins

107 views
Skip to first unread message

AndyB

unread,
Jul 28, 2017, 10:27:43 AM7/28/17
to Xataface
Hi All,

Just followed documented steps to setup user login screen on my app.

The “Log In” button/text appears but when clicked I get a blank screen.

I’ve created tbl_admin to hold the username and password.


CREATE TABLE IF NOT EXISTS `tbl_admin` (
  `UserID` mediumint(5) unsigned zerofill NOT NULL AUTO_INCREMENT,
  `Email` varchar(40) NOT NULL,
  `Codeword` varchar(32) NOT NULL,
  `Role` enum('No Access','Read Only','Edit','Delete','Owner','User','Admin') DEFAULT 'Read Only',
  `CountryID` mediumint(5) unsigned zerofill NOT NULL,
  `Phone` varchar(20) NOT NULL,
  `DateLoaded` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`UserID`),
  UNIQUE KEY `Email` (`Email`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

Codeword the password field is encrypted as a MD5 using table fields.ini and xataface table edit screen. Contents confirmed via MySQL phpMyAdmin utility screen.


I’ve added [_Auth] into conf.ini

[_auth]

                users_table=tbl_admin

                username_column=Email

                password_column=Codeword

 

When I add the function getPermissions code into conf/ApplicationDelegate.php the app just returns a blank screen.
FYI function beforeHandleRequest() previously inserted by me to change my logo image, and works!
 
<?php
class conf_ApplicationDelegate{
                    function beforeHandleRequest() {
                                         $app = dataface_Application::getInstance();
                                         $app->addHeadContent(sprintf('<link rel="stylesheet" type="text/css" href="%s"/>',
                                                             htmlspecialchars(DATAFACE_SITE_URL.'/style.css')
                                                             ));                             
                                         $query =& $app->getQuery();
                                         if (isset($query['-path'])){
                                                             languageUtilities::setLanguageFromPath($query['-path']);
                                         }
                    }
 
                    function getPermissions(&$record){
                        $auth =& Dataface_AuthenticationTool::getInstance();
                        $user =& $auth->getLoggedInUser();
                        if ( !isset($user) ) return Dataface_PermissionsTool::NO_ACCESS();
                            // if the user is null then nobody is logged in... no access.
                            // This will force a login prompt.
                        $role = $user->val('Role');
                        return Dataface_PermissionsTool::getRolePermissions($role);
                            // Returns all of the permissions for the user's current role.
                     }
}
?>

When I remove the function getPermissions code, app runs fine but login screen is blank.

Error log shows the following.

[Fri Jul 28 14:18:57 2017] [error] PHP Warning:  Cannot modify header information - headers already sent by (output started at /var/www/vhosts/53/284764/webspace/httpdocs/mydomainname.com/myapp/index.php:1) in /var/www/vhosts/53/284764/webspace/httpdocs/mydomainname.com/myapp/xataface/js.php on line 13

 

[Fri Jul 28 14:19:25 2017] [error] PHP Warning:  Cannot modify header information - headers already sent by (output started at /var/www/vhosts/53/284764/webspace/httpdocs/mydomainname.com/myapp/index.php:1) in /var/www/vhosts/53/284764/webspace/httpdocs/mydomainname.com/myapp/xataface/Dataface/Application.php on line 878

 

[Fri Jul 28 14:19:25 2017] [error] PHP Warning:  Cannot modify header information - headers already sent by (output started at /var/www/vhosts/53/284764/webspace/httpdocs/mydomainname.com/myapp/index.php:1) in /var/www/vhosts/53/284764/webspace/httpdocs/mydomainname.com/myapp/xataface/Dataface/Application.php on line 1584

 

[Fri Jul 28 14:19:25 2017] [error] PHP Warning:  session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/vhosts/53/284764/webspace/httpdocs/mydomainname.com/myapp/index.php:1) in /var/www/vhosts/53/284764/webspace/httpdocs/mydomainname.com/myapp/xataface/Dataface/Application.php on line 1716

 

What have a missed ? Any thoughts?

 Thanks

Regards

AndyB

Edward Spiegel

unread,
Jul 28, 2017, 11:26:49 AM7/28/17
to xata...@googlegroups.com
Check your php file to make sure there aren't any blank lines or spaces before the php tag.

best,
Edward

--
You received this message because you are subscribed to the Google Groups "Xataface" group.
Visit this group at https://groups.google.com/group/xataface.
To view this discussion on the web visit https://groups.google.com/d/msgid/xataface/307f8771-1c9d-4a64-a51e-0e1f9b08fc27%40googlegroups.com.

AndyB

unread,
Jul 29, 2017, 8:11:52 AM7/29/17
to Xataface
Thanks Edward,
I'll check that out.

Regards
AndyB

AndyB

unread,
Aug 1, 2017, 7:41:56 AM8/1/17
to Xataface
Hi Edward,
I've checked the file but I've had no luck. I've gone through the documentation again but I wonder have I missed a module install / upgrade somewhere along the way?

Regards
AndyB

Edward Spiegel

unread,
Aug 1, 2017, 11:02:36 AM8/1/17
to xata...@googlegroups.com
Hi Andy,

If you haven't done so, do a Google search and read up on the meaning of that error message then take a look at the lines of code that are getting the errors AND double-check the order that things are called in index.php. It sounds like multiple routines are trying to write header information at times when it is not allowed.

Best,
Edward

AndyB

unread,
Aug 1, 2017, 1:59:37 PM8/1/17
to Xataface
Cheers Edward,
Thing is I'm only using the standard generic routines supplied. I've not implemented any new code or any routines other than the various table field.ini, valuelist.ini files and implementing the depselect function.

So I'm wondering did I miss running an updated install routine somewhere outside of the standard documentation I've been reading.

Regards
AndyB

AndyB

unread,
Aug 3, 2017, 11:33:00 AM8/3/17
to Xataface
Hi All,
So I switched on messages from within the index.php file using

error_reporting(E_ALL);
ini_set('display_errors', 'on');

and the following is displayed when I click the login option

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/53/284764/webspace/httpdocs/domainname.com/myapp/index.php:1
in /var/www/vhosts/53/284764/webspace/httpdocs/domainname.com/myapp/xataface/Dataface/Application.php on line 878 

- > The Code on line 878 is  setcookie($prefix.'lang', $this->_conf['lang'], null, '/');

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/53/284764/webspace/httpdocs/domainname.com/myapp/index.php:1
in /var/www/vhosts/53/284764/webspace/httpdocs/domainname.com/myapp/xataface/Dataface/Application.php on line 1584 

-> The Code on line 1584 is setcookie($this->sessionCookieKey, 1, 0, DATAFACE_SITE_URL);

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/vhosts/53/284764/webspace/httpdocs/domainname.com/myapp/index.php:1
in /var/www/vhosts/53/284764/webspace/httpdocs/domainname.com/myapp/xataface/Dataface/Application.php on line 1716 

-> The Code on line 1716 is session_start(); // start the session

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/vhosts/53/284764/webspace/httpdocs/domainname.com/myapp/index.php:1
in /var/www/vhosts/53/284764/webspace/httpdocs/domainname.com/myapp/xataface/Dataface/Application.php on line 1716 

-> The Code on line 1717 is      As above!

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/53/284764/webspace/httpdocs/domainname.com/myapp/index.php:1
in /var/www/vhosts/53/284764/webspace/httpdocs/domainname.com/myapp/xataface/Dataface/Application.php on line 1717 

-> The Code on line 1717 is header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/53/284764/webspace/httpdocs/domainname.com/myapp/index.php:1
in /var/www/vhosts/53/284764/webspace/httpdocs/domainname.com/myapp/xataface/Dataface/AuthenticationTool.php on line 470 

-> The Code on line 470 os header("Location: $url");

Anyone out there in Xataface land have any suggestions how I can get the login functionality to work?

Regards
AndyB


On Tuesday, 1 August 2017 16:02:36 UTC+1, Edward Spiegel wrote:

Steve Hannah

unread,
Aug 3, 2017, 11:41:00 AM8/3/17
to xata...@googlegroups.com
You have whitespace on line 1 of your index.php file.  Remove it by making sure that the opening <?php tag is at the absolute beginning of the file.




--
Steve Hannah
Web Lite Solutions Corp.

AndyB

unread,
Aug 3, 2017, 3:30:20 PM8/3/17
to Xataface
Hi Steve,
Using view options in Notepad ++ I couldn't find any white spaces, so, I re-created a new index file from scratch and hey presto the login screen works.

Thanks very much.

Regards
AndyB

Steve Hannah

unread,
Aug 3, 2017, 4:09:02 PM8/3/17
to xata...@googlegroups.com
Notepad++ must add a unicode BOM character.  I don't use Notepad++ but I suspect there must be a way to either not add that character, or view hidden characters.

Edward Spiegel

unread,
Aug 3, 2017, 5:33:23 PM8/3/17
to xata...@googlegroups.com
If Notepad did not show you the blank line, check to see if it has a plain ASCII mode. If it doesn't, you might want to switch to a text editor (there are good free ones) built for coding.

Just my opinion,
Edward

AndyB

unread,
Aug 4, 2017, 5:26:58 AM8/4/17
to Xataface
Thanks Steve and Edward,
I did a project sometime back and had to use Notepad ++ so just kept using it, looks like back to good old MS notepad!

Regards
AndyB

Steve Hannah

unread,
Aug 5, 2017, 12:47:34 PM8/5/17
to xata...@googlegroups.com
NOOOO.  Not notepad.  Anything but notepad.  Seriously.

I recommend Atom.   Or Netbeans.

AndyB

unread,
Aug 7, 2017, 12:52:27 PM8/7/17
to Xataface
Cheers Steve,

Notepad advice noted.

Regards
AndyB
Reply all
Reply to author
Forward
0 new messages