|
|
@ -78,14 +78,15 @@ export default function LoginScreen(props) { |
|
|
|
const authContext = useContext(AuthContext); |
|
|
|
|
|
|
|
const handleSubmit = async (name, password, setLoginFailed) => { |
|
|
|
const result = login(name, password);//await authApi.login(name, password);
|
|
|
|
const result = await login(name, password); |
|
|
|
console.log(JSON.stringify(result)); |
|
|
|
|
|
|
|
if (!result.ok) return setLoginFailed(true); |
|
|
|
|
|
|
|
setLoginFailed(false); |
|
|
|
const user = jwdDecode(result.data); |
|
|
|
authContext.setUser(user); |
|
|
|
console.log(user); |
|
|
|
console.log("usuário: " + JSON.sstringify(user)); |
|
|
|
authStorage.setToken(result.data); |
|
|
|
}; |
|
|
|
|
|
|
|