Just to say, I'm a complete newbie so apologies in advance.
My client needs to move his Flash+Classic ASP website across to a Linux server. I've decided to use it as a test case for learning Laravel but I've hit a brick wall.
The Flash movies need to access the database for login and so on, which they currently do using some simple ASP. Converting that to PHP/Laravel isn't a problem but, although I have access to the original Flash files, I'd rather try and keep the movies as they are and route the URL requests for the .asp files to PHP instead. If that's even possible!
I've set up the following in routes.php:
Route::post('/updateUser.asp', 'UserController@loginUser');
And the loginUser() method in the UserController looks like this:
function loginUser()
{
$email = Input::get('email');
$password = Input::get('password');
$user = DB::table('alluserdetails')
->where('email', '=', $email)
->where('userpassword', '=', $password)
->get();
if($user){
return "userInfo=true";
} else {
return "userInfo=false";
}
}
So, in my mind that all makes sense... request to updateUser.asp instead goes to the userInfo() method and returns 'userInfo=true' or 'userInfo=false' (which is what the Flash movie needs).
I don't get any error messages, just... nothing.
I was thinking it'd make more sense to have the Input::get('email') and Input::get('password') in the route, but I can't seem to work out how to pass parameters across when using POST?
Have I gone about it in a ridiculous way? Any help would be enormously appreciated.
Andrew
(Yes, I know Flash is awful etc. but converting the whole thing to HTML5 is a job for another day/year - and please excuse the general rubbish/insecure nature of the code; it's just a proof of concept at this stage).
"""Have I gone about it in a ridiculous way?"""
Kind of, laravel has a built in auth method so no need to query the DB directly like that. There is a better way
Just so you know.... Your method likely won't find a user because you are checking the plain text version of the password as the user enters it into a form and comparing it to, what I hope, is an encrypted password stored in the DB.
The better way is to use the built in auth method.
public function authUser() {
if(Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password')), true)) {
return Redirect::intended('home')->with('message', 'Login Success');
} else {
return Redirect::route('login')->with('message', 'Login Failed');
}
}
Thanks for your reply, IanSirkit.
"[...]what I hope, is an encrypted password stored in the DB."
Unfortunately not - all passwords are plaintext (it goes without saying, I've inherited an absolute mess).
That's the next thing on my list to sort but at the moment I'm just trying to get everything working so I can then go back and improve wherever possible.
So, thank you very much for the advice with Auth, but it won't work in this case unfortunately.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community