complete authentication flow and email verification link implementation #232
|
@ -53,7 +53,7 @@ class EmailCollectPage extends React.PureComponent {
|
|||
![]() No aliases (or resolves) for paths? No aliases (or resolves) for paths?
*Remove the long relative paths
![]() Don’t need a full constructor (see comment above) Don’t need a full constructor (see comment above)
![]() This is a legacy lifecycle method, should use This is a legacy lifecycle method, should use `getDerivedStateFromProps`
|
||||
}).catch(error => {
|
||||
this.setState({ authenticationFailed: true });
|
||||
});
|
||||
}, useTimeout ? 5000 : 0); // if useTimeout is set, wait 5s to give the daemon some time to start
|
||||
![]() No aliases (or resolves) for paths? No aliases (or resolves) for paths?
*Remove the long relative paths
![]() Don’t need a full constructor (see comment above) Don’t need a full constructor (see comment above)
![]() This is a legacy lifecycle method, should use This is a legacy lifecycle method, should use `getDerivedStateFromProps`
|
||||
}, useTimeout ? 10000 : 0); // if useTimeout is set, wait 10s to give the daemon some time to start
|
||||
![]() No aliases (or resolves) for paths? No aliases (or resolves) for paths?
*Remove the long relative paths
![]() Don’t need a full constructor (see comment above) Don’t need a full constructor (see comment above)
![]() This is a legacy lifecycle method, should use This is a legacy lifecycle method, should use `getDerivedStateFromProps`
|
||||
}
|
||||
|
||||
handleChangeText = (text) => {
|
||||
|
|
|||
![]() No aliases (or resolves) for paths? No aliases (or resolves) for paths?
*Remove the long relative paths
![]() Don’t need a full constructor (see comment above) Don’t need a full constructor (see comment above)
![]() This is a legacy lifecycle method, should use This is a legacy lifecycle method, should use `getDerivedStateFromProps`
![]() No aliases (or resolves) for paths? No aliases (or resolves) for paths?
*Remove the long relative paths
![]() Don’t need a full constructor (see comment above) Don’t need a full constructor (see comment above)
![]() This is a legacy lifecycle method, should use This is a legacy lifecycle method, should use `getDerivedStateFromProps`
|
|
@ -22,13 +22,15 @@ class SplashScreen extends React.PureComponent {
|
|||
|
||||
componentWillMount() {
|
||||
this.setState({
|
||||
daemonReady: false,
|
||||
details: 'Starting daemon',
|
||||
message: 'Connecting',
|
||||
isRunning: false,
|
||||
isLagging: false,
|
||||
launchUrl: null,
|
||||
isDownloadingHeaders: false,
|
||||
headersDownloadProgress: 0
|
||||
headersDownloadProgress: 0,
|
||||
shouldAuthenticate: false
|
||||
});
|
||||
|
||||
if (NativeModules.DaemonServiceControl) {
|
||||
|
@ -56,7 +58,7 @@ class SplashScreen extends React.PureComponent {
|
|||
componentWillUpdate(nextProps) {
|
||||
const { navigation, verifyUserEmail, verifyUserEmailFailure } = this.props;
|
||||
const { user } = nextProps;
|
||||
if (user && user.id) {
|
||||
if (this.state.daemonReady && this.state.shouldAuthenticate && user && user.id) {
|
||||
// user is authenticated, navigate to the main view
|
||||
const resetAction = NavigationActions.reset({
|
||||
index: 0,
|
||||
|
@ -106,6 +108,7 @@ class SplashScreen extends React.PureComponent {
|
|||
// TODO: This is a hack, and the logic should live in the daemon
|
||||
// to give us a better sense of when we are actually started
|
||||
this.setState({
|
||||
daemonReady: true,
|
||||
message: 'Testing Network',
|
||||
details: 'Waiting for name resolution',
|
||||
isLagging: false,
|
||||
|
@ -121,8 +124,18 @@ class SplashScreen extends React.PureComponent {
|
|||
notify
|
||||
} = this.props;
|
||||
|
||||
authenticate(null);
|
||||
balanceSubscribe();
|
||||
NativeModules.VersionInfo.getAppVersion().then(appVersion => {
|
||||
if (NativeModules.UtilityModule) {
|
||||
// authenticate with the device ID if the method is available
|
||||
NativeModules.UtilityModule.getDeviceId().then(deviceId => {
|
||||
authenticate(`android-${appVersion}`, deviceId);
|
||||
});
|
||||
} else {
|
||||
authenticate(appVersion);
|
||||
}
|
||||
this.setState({ shouldAuthenticate: true });
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -172,19 +172,10 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
|
|||
Toast.makeText(context, "Rewards cannot be claimed because we could not identify your device.", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-384");
|
||||
md.update(id.getBytes("UTF-8"));
|
||||
String hash = new BigInteger(1, md.digest()).toString(16);
|
||||
|
||||
SharedPreferences sp = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putString(DEVICE_ID_KEY, hash);
|
||||
editor.commit();
|
||||
} catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) {
|
||||
// SHA-384 not found, UTF-8 encoding not supported
|
||||
Toast.makeText(context, "Rewards cannot be claimed because we could not identify your device.", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
SharedPreferences sp = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putString(DEVICE_ID_KEY, id);
|
||||
editor.commit();
|
||||
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -2,13 +2,17 @@ package io.lbry.browser.reactmodules;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.facebook.react.bridge.Promise;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
|
||||
import io.lbry.browser.MainActivity;
|
||||
|
||||
public class UtilityModule extends ReactContextBaseJavaModule {
|
||||
private Context context;
|
||||
|
||||
|
@ -71,4 +75,11 @@ public class UtilityModule extends ReactContextBaseJavaModule {
|
|||
View.SYSTEM_UI_FLAG_VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void getDeviceId(final Promise promise) {
|
||||
SharedPreferences sp = context.getSharedPreferences(MainActivity.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
String deviceId = sp.getString(MainActivity.DEVICE_ID_KEY, null);
|
||||
promise.resolve(deviceId);
|
||||
}
|
||||
}
|
||||
|
|
No aliases (or resolves) for paths?
*Remove the long relative paths
Don’t need a full constructor (see comment above)
This is a legacy lifecycle method, should use
getDerivedStateFromProps