Change login password in the Standard

Asked

Viewed 225 times

0

I am trying to change the login password of the user in Windows, to log in I use Auth::atempt and as a parameter email and password, this password does not exist in my users table. Where does the reader get this password? I tried to change this way and got the error below:

    function login(Request $request){
        if (Auth::attempt(['email' => $request->email, 'password' => $request->senha])){
            return response()->json([
                'token' => str_random(60),
                'usuario_recruta' => Auth::User()->usuario_recruta,
                'nomeUsuario' => Auth::User()->nome,
                'idUsuario' =>Auth::User()->id,
                'mensagem' => 'Autenticado com sucesso',
            ], 202);
        }else{
        return response()->json([
        'error' => 'Nome de usuário ou senha incorretos',
        'code' => 401,], 401);
    }
}

The login works normally even if I don’t have the column "password" in my bd. I switched from password to "password", but continues to log in normal.

So I tried to change it this way:

function alteraDadosPerfil($id, Request $request){
    $dadosPerfil = User::find($id);


    $dadosPerfil->password = $request->senha;

    $dadosPerfil->save();
    return response()->json($dadosPerfil, 200);
}

I get:

Unknown column 'password' in 'field list'

I tried too:

$dadosPerfil->senha = Hash::make($request->senha);

$dadosPerfil->save();

But this way I can not login with the changed password

How I change the password in the language via api?

  • What are the table fields!?

  • And why you changed the table!?

  • I switched to password because I wanted to keep in Portuguese

  • But I already did, I’ll add my answer when I have time

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.