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