[SOLVED] Issues With "Undefined" login/register error

I have just installed EMONCMS on a fresh server.

I seem to be having issues when registering or when logging in.

I fill in the requied fields then when i click on login it returns a red box with “undefined” in it.

has anyone else come accross this?

pete

Hi Pete,

Try a longer username, when I try with a two character user name I get error Username length error, maybe this is the issue and your install is just throwing a default ‘undefined’ error.

same error even with a longer username.

The error is undefined still.

Any other ideas??

I have the same on a local install on my NAS, never found what element is missing in php … spits tons of css errors but nothing really useful.

Right, found the issue.

The user/ directory is missing from the git clone.

ive compared the Modules/user/user.js file from that of the one on emoncms.org its the same, however its clear that my and possibly @bidouilleur installation is missing the actual /user/register.json and login.json files

'login':function(username,password,rememberme) { var result ={}; $.ajax({ type: "POST", url: path+"user/login.json", data: "&username="+username+"&password="+encodeURIComponent(password)+"&rememberme="+rememberme, dataType: 'json', async: false, success: function(data) { result = data; } }); return result; },

Where do i locate these as they dont appear to be on the git fork

Pete

Not sure but the problem is related to .htaccess and mod_rewrite if I remember well
when you uploaded the files, did you upload the .htaccess file (invisible on mac for exemple if you don’t know)
Else make one with following content

# Various rewrite rules.
#<IfModule mod_rewrite.c>
#  RewriteEngine on
 
  #RewriteBase /sites/emon/
 # RewriteBase /monitor/

 <IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /
 RewriteRule ^index\.php$ - [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_URI} !=/favicon.ico
 RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
 </IfModule>

sorry, code insert ain’t easy on this forum, image for now

On my hosting server emoncms works flawless so it is related to my NAS rewrite module

(edit : code correctly inserted in post thanks to Jon’s wise advice)

thanks.

ive checked that.

Ive confirmed that mod rewrite is installed and it has the correct file permissions

im now lost.

Hi

Issue Fixed.

I amended the apache2.conf file in debian as per:
http://www.jarrodoberto.com/articles/2011/11/enabling-mod-rewrite-on-ubuntu

and added
Options Indexes FollowSymLinks
to the .htaccess file.

This then functioned correctly.

Pete

1 Like

Hi Pete,

Nice work, getting to the bottom of this :grinning: .

Are there any changes you would recommend us making to the install guide to avoid this next time.

The changes you mentioned to apache2.conf in your link look identical to the changes mentioned in the install guide:

Emoncms uses a front controller to route requests, modrewrite needs to be configured:

    sudo a2enmod rewrite
    
For `<Directory />` and `<Directory /var/www/>` change `AllowOverride None` to `AllowOverride All`. This may be on lines 7 and 11 of `/etc/apache2/sites-available/default`. Modern versions of Ubuntu store these in the main config file: `/etc/apache2/apache2.conf`.
    
    sudo nano /etc/apache2/sites-available/default
    
or

    sudo nano /etc/apache2/apache2.conf

[Ctrl + X ] then [Y] then [Enter] to Save and exit.

Restart the lamp server:

    sudo service apache2 restart

Did you follow these steps?

Why are the changes you made to htaccess required? Following symlinks should not be needed. Unless you symlinked the files into your web directory. Would you recommend these changes be made default?

I used a fresh installation and i had to create a .htaccess file on my own.
Now it works. Before that i had the same “undefined” problem.