@@ -95,43 +95,38 @@ const AuthForm = ({ navigation }) => {
9595 api
9696 . post ( '/auth' , { code : passcode } )
9797 . then ( async ( res ) => {
98- try {
99- const { data } = res ;
100- // save session
101- const bearerToken = data . syncToken ;
102- api . setToken ( bearerToken ) ;
103-
104- await crudConfig . updateConfig ( { authenticationCode : passcode } ) ;
105- await cascades . createSqliteDir ( ) ;
106- // update auth state
107- AuthState . update ( ( s ) => {
108- s . authenticationCode = passcode ;
109- s . token = bearerToken ;
110- } ) ;
111-
112- const userID = await handleActiveUser ( {
113- ...data ,
114- passcode,
115- administrationList : JSON . stringify ( data . administrations ) ,
116- } ) ;
117-
118- await handleGetAllForms ( data . formsUrl , userID ) ;
119-
120- // go to home page (form list)
121- setTimeout ( ( ) => {
122- navigation . navigate ( 'Home' , { newForms : true } ) ;
123- } , 500 ) ;
124- } catch ( err ) {
125- console . error ( err ) ;
126- }
98+ const { data } = res ;
99+ // save session
100+ const bearerToken = data . syncToken ;
101+ api . setToken ( bearerToken ) ;
102+
103+ await crudConfig . updateConfig ( { authenticationCode : passcode } ) ;
104+ await cascades . createSqliteDir ( ) ;
105+ // update auth state
106+ AuthState . update ( ( s ) => {
107+ s . authenticationCode = passcode ;
108+ s . token = bearerToken ;
109+ } ) ;
110+
111+ const userID = await handleActiveUser ( {
112+ ...data ,
113+ passcode,
114+ administrationList : JSON . stringify ( data . administrations ) ,
115+ } ) ;
116+
117+ await handleGetAllForms ( data . formsUrl , userID ) ;
118+
119+ // go to home page (form list)
120+ setTimeout ( ( ) => {
121+ navigation . navigate ( 'Home' , { newForms : true } ) ;
122+ } , 500 ) ;
127123 } )
128124 . catch ( ( err ) => {
129- const { status : errStatus , message : errMessage } = err ?. response ;
130- if ( [ 400 , 401 ] . includes ( errStatus ) ) {
131- setError ( trans . authErrorPasscode ) ;
125+ const { status : errorCode } = err ?. response ;
126+ if ( [ 400 , 401 ] . includes ( errorCode ) ) {
127+ setError ( ` ${ errorCode } : ${ trans . authErrorPasscode } ` ) ;
132128 } else {
133- console . log ( 'errStatus' , err ?. message ) ;
134- setError ( errMessage ) ;
129+ setError ( `${ errorCode } : ${ err ?. message } ` ) ;
135130 }
136131 } )
137132 . finally ( ( ) => setLoading ( false ) ) ;
0 commit comments