File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import axios, {
66 AxiosResponse ,
77 InternalAxiosRequestConfig ,
88} from "axios"
9- import { PolimiToken , PoliNetworkToken , Tokens } from "./schemas"
9+ import { PolimiToken , PoliNetworkToken , Tokens , tokensSchema } from "./schemas"
1010import AsyncStorage from "@react-native-async-storage/async-storage"
1111import { wait } from "utils/functions"
1212import { Alert } from "react-native"
@@ -432,8 +432,7 @@ export class HttpClient extends EventEmitter {
432432 async loadTokens ( ) {
433433 const tokens = await AsyncStorage . getItem ( "api:tokens" )
434434 if ( tokens ) {
435- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
436- const parsedTokens : Tokens = JSON . parse ( tokens )
435+ const parsedTokens : Tokens = tokensSchema . parse ( JSON . parse ( tokens ) )
437436 console . log ( "Loaded tokens from local storage" )
438437 this . polimiToken = parsedTokens . polimiToken
439438 this . poliNetworkToken = parsedTokens . poliNetworkToken
Original file line number Diff line number Diff line change @@ -6,7 +6,11 @@ import WebView from "react-native-webview"
66import { usePalette } from "utils/colors"
77import { api } from "api"
88import { HttpClient } from "api/HttpClient"
9- import { PolimiToken , PoliNetworkToken } from "api/schemas"
9+ import {
10+ PolimiToken ,
11+ PoliNetworkToken ,
12+ poliNetworkTokenSchema ,
13+ } from "api/schemas"
1014import { NavBar } from "components/NavBar"
1115
1216// TODO: HANDLE ERRORS, this will break as soon as something goes wrong
@@ -132,8 +136,9 @@ export const Login: RootStackScreen<"Login"> = () => {
132136
133137 if ( url . startsWith ( polinetworkTargetUrl ) ) {
134138 try {
135- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
136- setPoliNetworkToken ( JSON . parse ( data ) )
139+ setPoliNetworkToken (
140+ poliNetworkTokenSchema . parse ( JSON . parse ( data ) )
141+ )
137142 setCurrentURL ( magicTokenUrl )
138143 } catch ( e ) {
139144 console . log ( "error while parsing!!" )
You can’t perform that action at this time.
0 commit comments