I'm trying to create login function with react native and laravel.
Code
public function logIn(Request $request)
{
if (Auth::attempt(['email' => $request['email'], 'password' => $request['password']], Auth::getRecallerName())) {
$status = 200;
} else {
$status = 400;
}
return response()->json($status);
}
authPost = async() => {
axios
.post(baseApiUrl + '/api/logIn', {
email: this.state.email,
password: this.state.password
})
.then((res) => {
if(res.status === 200){
this.props.navigation.navigate('Home');
}else{
console.log('failed');
}
})
.catch(error => console.log(error));
}
This code is working.
I wanna make sure if a user has already logged in or not.
I would appreciate it if you could give me any advice.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire