I have a form with a 'name' textfield. When i press send laravel checks if the username exists. If so then go to the next page. I am using Jquery mobile.
But because of this error i am redirecting to the same page if the username exists. Just to be sure that the problem is not with the second mobile page.
When i enter a non-existing username i get redirected back to mobilepage1. No problem here. But if i enter a right username Jquery gives me an error.: 'error loading page'. So laravel recognizes i have filled in the right username. But why the error? I am redirecting to the same page.
This is my controller code:
$input = Input::all();
$credentials = array('username' => $input['name']);
if(Auth::attempt($credentials)){
return View::make('mobilepages.mobilepage1');
} else {
return View::make('mobilepages.mobilepage1');
}
Also i am using a second database connection in laravel:
my 'User' model looks like this:
<?php
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
class User extends Eloquent implements UserInterface, RemindableInterface {
/**
* The database table used by the model.
*
* @var string
*/
protected $connection = 'mysql2';
protected $table = 'users';
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = array('password');
/**
* Get the unique identifier for the user.
*
* @return mixed
*/
public function getAuthIdentifier()
{
return $this->getKey();
}
/**
* Get the password for the user.
*
* @return string
*/
public function getAuthPassword()
{
return $this->password;
}
/**
* Get the e-mail address where password reminders are sent.
*
* @return string
*/
public function getReminderEmail()
{
return $this->email;
}
Have you checked your logs (app/storage/*) to see what error is being thrown? If it's doing an AJAX request to get the page have you used an inspector to see what the response is?
Also, you are missing the last ' in this code.
return View::make('mobilepages.mobilepage1);
The inspector showed that a password is needed as an input. So i added a password field and validation. Now the app works :D
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community