fix: incorrect redirect on failed sign up
This commit is contained in:
+24
-10
@@ -122,6 +122,8 @@ class TinodeWeb extends React.Component {
|
||||
connected: false,
|
||||
// Connected and subscribed to 'me'
|
||||
ready: false,
|
||||
// Try to re-login on new connection.
|
||||
autoLogin: false,
|
||||
transport: settings.transport || null,
|
||||
serverAddress: settings.serverAddress || detectServerAddress(),
|
||||
serverVersion: "no connection",
|
||||
@@ -266,7 +268,7 @@ class TinodeWeb extends React.Component {
|
||||
}
|
||||
|
||||
handleResize() {
|
||||
var mobile = document.documentElement.clientWidth <= MEDIA_BREAKPOINT;
|
||||
const mobile = document.documentElement.clientWidth <= MEDIA_BREAKPOINT;
|
||||
this.setState({
|
||||
viewportWidth: document.documentElement.clientWidth,
|
||||
viewportHeight: document.documentElement.clientHeight
|
||||
@@ -291,7 +293,7 @@ class TinodeWeb extends React.Component {
|
||||
|
||||
// Handle for hashchange event: display appropriate panels.
|
||||
handleHashRoute() {
|
||||
var hash = HashNavigation.parseUrlHash(window.location.hash);
|
||||
const hash = HashNavigation.parseUrlHash(window.location.hash);
|
||||
if (hash.path && hash.path.length > 0) {
|
||||
// Left-side panel selector.
|
||||
if (['register','settings','edit','cred','reset','newtpk','archive','contacts',''].includes(hash.path[0])) {
|
||||
@@ -327,9 +329,8 @@ class TinodeWeb extends React.Component {
|
||||
}
|
||||
|
||||
handleOnline(online) {
|
||||
var newState = {liveConnection: online};
|
||||
if (online) {
|
||||
this.handleError('', null);
|
||||
this.handleError();
|
||||
} else {
|
||||
this.handleError("No connection", 'warn');
|
||||
}
|
||||
@@ -367,11 +368,14 @@ class TinodeWeb extends React.Component {
|
||||
|
||||
// Connection succeeded.
|
||||
handleConnected() {
|
||||
var params = this.tinode.getServerInfo();
|
||||
const params = this.tinode.getServerInfo();
|
||||
this.setState({
|
||||
serverVersion: params.ver + ' ' + (params.build ? params.build : 'none') + '; '
|
||||
});
|
||||
this.doLogin(this.state.login, this.state.password, {meth: this.state.credMethod, resp: this.state.credCode});
|
||||
|
||||
if (this.state.autoLogin) {
|
||||
this.doLogin(this.state.login, this.state.password, {meth: this.state.credMethod, resp: this.state.credCode});
|
||||
}
|
||||
}
|
||||
|
||||
// Called for each auto-reconnect iteration.
|
||||
@@ -477,21 +481,21 @@ class TinodeWeb extends React.Component {
|
||||
}
|
||||
|
||||
handleCredentialsRequest(params) {
|
||||
var parsed = HashNavigation.parseUrlHash(window.location.hash);
|
||||
const parsed = HashNavigation.parseUrlHash(window.location.hash);
|
||||
parsed.path[0] = 'cred';
|
||||
parsed.params['method'] = params.cred[0];
|
||||
HashNavigation.navigateTo(HashNavigation.composeUrlHash(parsed.path, parsed.params));
|
||||
}
|
||||
|
||||
handleLoginSuccessful() {
|
||||
this.handleError('', null);
|
||||
this.handleError();
|
||||
|
||||
// Refresh authentication token.
|
||||
if (LocalStorageUtil.getObject('keep-logged-in')) {
|
||||
LocalStorageUtil.setObject('auth-token', this.tinode.getAuthToken());
|
||||
}
|
||||
// Logged in fine, subscribe to 'me' attaching callbacks from the contacts view.
|
||||
var me = this.tinode.getMeTopic();
|
||||
const me = this.tinode.getMeTopic();
|
||||
me.onMetaDesc = this.tnMeMetaDesc;
|
||||
me.onContactUpdate = this.tnMeContactUpdate;
|
||||
me.onSubsUpdated = this.tnMeSubsUpdated;
|
||||
@@ -499,7 +503,8 @@ class TinodeWeb extends React.Component {
|
||||
connected: true,
|
||||
credMethod: undefined,
|
||||
credCode: undefined,
|
||||
myUserId: this.tinode.getCurrentUserID()
|
||||
myUserId: this.tinode.getCurrentUserID(),
|
||||
autoLogin: true,
|
||||
});
|
||||
// Subscribe, fetch topic desc, the list of subscriptions. Messages are not fetched.
|
||||
me.subscribe(
|
||||
@@ -803,11 +808,16 @@ class TinodeWeb extends React.Component {
|
||||
|
||||
// User chose a Sign Up menu item.
|
||||
handleNewAccount() {
|
||||
this.handleError();
|
||||
|
||||
HashNavigation.navigateTo(HashNavigation.setUrlSidePanel(window.location.hash, 'register'));
|
||||
}
|
||||
|
||||
// Actual registration of a new account.
|
||||
handleNewAccountRequest(login_, password_, public_, cred_, tags_) {
|
||||
// Clear old error, if any.
|
||||
this.handleError();
|
||||
|
||||
this.tinode.connect(this.state.serverAddress)
|
||||
.then(() => {
|
||||
return this.tinode.createAccountBasic(login_, password_,
|
||||
@@ -824,6 +834,8 @@ class TinodeWeb extends React.Component {
|
||||
}
|
||||
|
||||
handleUpdateAccountRequest(password, pub, defacs) {
|
||||
this.handleError();
|
||||
|
||||
if (pub || defacs) {
|
||||
const params = {};
|
||||
if (pub) {
|
||||
@@ -852,6 +864,8 @@ class TinodeWeb extends React.Component {
|
||||
|
||||
// User chose Settings menu item.
|
||||
handleSettings() {
|
||||
this.handleError();
|
||||
|
||||
HashNavigation.navigateTo(HashNavigation.setUrlSidePanel(window.location.hash,
|
||||
this.state.myUserId ? 'edit' : 'settings'));
|
||||
}
|
||||
|
||||
+17
-11
@@ -4724,6 +4724,7 @@ var TinodeWeb = function (_React$Component) {
|
||||
return {
|
||||
connected: false,
|
||||
ready: false,
|
||||
autoLogin: false,
|
||||
transport: settings.transport || null,
|
||||
serverAddress: settings.serverAddress || Object(_lib_host_name_js__WEBPACK_IMPORTED_MODULE_13__["detectServerAddress"])(),
|
||||
serverVersion: "no connection",
|
||||
@@ -4925,12 +4926,8 @@ var TinodeWeb = function (_React$Component) {
|
||||
}, {
|
||||
key: "handleOnline",
|
||||
value: function handleOnline(online) {
|
||||
var newState = {
|
||||
liveConnection: online
|
||||
};
|
||||
|
||||
if (online) {
|
||||
this.handleError('', null);
|
||||
this.handleError();
|
||||
} else {
|
||||
this.handleError("No connection", 'warn');
|
||||
}
|
||||
@@ -4991,10 +4988,13 @@ var TinodeWeb = function (_React$Component) {
|
||||
this.setState({
|
||||
serverVersion: params.ver + ' ' + (params.build ? params.build : 'none') + '; '
|
||||
});
|
||||
this.doLogin(this.state.login, this.state.password, {
|
||||
meth: this.state.credMethod,
|
||||
resp: this.state.credCode
|
||||
});
|
||||
|
||||
if (this.state.autoLogin) {
|
||||
this.doLogin(this.state.login, this.state.password, {
|
||||
meth: this.state.credMethod,
|
||||
resp: this.state.credCode
|
||||
});
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "handleAutoreconnectIteration",
|
||||
@@ -5119,7 +5119,7 @@ var TinodeWeb = function (_React$Component) {
|
||||
value: function handleLoginSuccessful() {
|
||||
var _this7 = this;
|
||||
|
||||
this.handleError('', null);
|
||||
this.handleError();
|
||||
|
||||
if (_lib_local_storage_js__WEBPACK_IMPORTED_MODULE_14__["default"].getObject('keep-logged-in')) {
|
||||
_lib_local_storage_js__WEBPACK_IMPORTED_MODULE_14__["default"].setObject('auth-token', this.tinode.getAuthToken());
|
||||
@@ -5133,7 +5133,8 @@ var TinodeWeb = function (_React$Component) {
|
||||
connected: true,
|
||||
credMethod: undefined,
|
||||
credCode: undefined,
|
||||
myUserId: this.tinode.getCurrentUserID()
|
||||
myUserId: this.tinode.getCurrentUserID(),
|
||||
autoLogin: true
|
||||
});
|
||||
me.subscribe(me.startMetaQuery().withLaterSub().withDesc().withTags().withCred().build()).catch(function (err) {
|
||||
_this7.tinode.disconnect();
|
||||
@@ -5423,6 +5424,7 @@ var TinodeWeb = function (_React$Component) {
|
||||
}, {
|
||||
key: "handleNewAccount",
|
||||
value: function handleNewAccount() {
|
||||
this.handleError();
|
||||
_lib_navigation_js__WEBPACK_IMPORTED_MODULE_15__["default"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_15__["default"].setUrlSidePanel(window.location.hash, 'register'));
|
||||
}
|
||||
}, {
|
||||
@@ -5430,6 +5432,7 @@ var TinodeWeb = function (_React$Component) {
|
||||
value: function handleNewAccountRequest(login_, password_, public_, cred_, tags_) {
|
||||
var _this14 = this;
|
||||
|
||||
this.handleError();
|
||||
this.tinode.connect(this.state.serverAddress).then(function () {
|
||||
return _this14.tinode.createAccountBasic(login_, password_, {
|
||||
public: public_,
|
||||
@@ -5451,6 +5454,8 @@ var TinodeWeb = function (_React$Component) {
|
||||
value: function handleUpdateAccountRequest(password, pub, defacs) {
|
||||
var _this15 = this;
|
||||
|
||||
this.handleError();
|
||||
|
||||
if (pub || defacs) {
|
||||
var params = {};
|
||||
|
||||
@@ -5489,6 +5494,7 @@ var TinodeWeb = function (_React$Component) {
|
||||
}, {
|
||||
key: "handleSettings",
|
||||
value: function handleSettings() {
|
||||
this.handleError();
|
||||
_lib_navigation_js__WEBPACK_IMPORTED_MODULE_15__["default"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_15__["default"].setUrlSidePanel(window.location.hash, this.state.myUserId ? 'edit' : 'settings'));
|
||||
}
|
||||
}, {
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user