Reputation: 4510
I have a web aplication where I can create Tecnico
TecnicoController (application web)
$tecnico = new Tecnico;
$tecnico->idTecnico = Input::get('idtecnico');
$tecnico->Nombre = Input::get('nombre');
$tecnico->Apellido = Input::get('apellido');
$tecnico->Telefono = Input::get('telefono');
$tecnico->Contrasena = Hash::make(Input::get('idtecnico')); //<--- hash of my pass, eg pass: 12 -> hash: $12345abc
$path = public_path().'/tecnico';
$fotoPerfil = Input::file('imagen');
$fotoPerfil->move($path, Input::get('idtecnico'));
$tecnico->Foto ='/tecnico/'.$tecnico->idTecnico;
$tecnico->save();
Also I have a different project, that works as a server to access the database from a mobile application. A Tecnico
from your cell phone can access your account by entering a contrasena
(password) and idTecnico
(id)
TecnicoController (server)
$idUnico = Input::get('idUnico');
$contrasena = Hash::make(Input::get('contrasena')); //<--- hash of my pass: eg pass: 12 -> hash: $146435gzc (change)
$tecnico = DB::table('Tecnico')->where('idTecnico', $idUnico)->where('Contrasena', $contrasena)->first();
The problem happens when you enter the password from the server. The Hashin creates a different value that exists in the database (when creating a Tecnico
).
How I can get the same hash value that is in the database?
Upvotes: 0
Views: 102
Reputation: 6301
Unfortunately you can't do this easily in a query, your best bet would be to grab the user and then compare the password, like so.
$idUnico = Input::get('idUnico');
$tecnico = DB::table('Tecnico')->where('idTecnico', $idUnico)->first();
if($tecnico) {
if(Hash::check(Input::get('contrasena'), $technico->Contrasena)) {
// passwords are the same
}
}
Upvotes: 1