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