Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
RocketChat
Rocket.Chat.ReactNative
Commits
e5ec5872
Commit
e5ec5872
authored
Mar 26, 2020
by
Djorkaeff Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] Logout when token expires
parent
7daa3092
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
3 deletions
+37
-3
app/lib/rocketchat.js
app/lib/rocketchat.js
+11
-1
patches/@rocket.chat+sdk+1.0.0-alpha.41.patch
patches/@rocket.chat+sdk+1.0.0-alpha.41.patch
+26
-2
No files found.
app/lib/rocketchat.js
View file @
e5ec5872
...
...
@@ -14,7 +14,9 @@ import { isIOS, getBundleId } from '../utils/deviceInfo';
import
{
extractHostname
}
from
'
../utils/server
'
;
import
fetch
,
{
BASIC_AUTH_KEY
}
from
'
../utils/fetch
'
;
import
{
setUser
,
setLoginServices
,
loginRequest
}
from
'
../actions/login
'
;
import
{
setUser
,
setLoginServices
,
loginRequest
,
logout
}
from
'
../actions/login
'
;
import
{
disconnect
,
connectSuccess
,
connectRequest
}
from
'
../actions/connect
'
;
import
{
shareSelectServer
,
shareSetUser
...
...
@@ -178,6 +180,10 @@ const RocketChat = {
this
.
closeListener
.
then
(
this
.
stopListener
);
}
if
(
this
.
unauthorizedListener
)
{
this
.
unauthorizedListener
.
then
(
this
.
unauthorizedListener
);
}
if
(
this
.
usersListener
)
{
this
.
usersListener
.
then
(
this
.
stopListener
);
}
...
...
@@ -224,6 +230,10 @@ const RocketChat = {
reduxStore
.
dispatch
(
disconnect
());
});
this
.
unauthorizedListener
=
this
.
sdk
.
onStreamData
(
'
unauthorized
'
,
()
=>
{
reduxStore
.
dispatch
(
logout
(
true
));
});
this
.
usersListener
=
this
.
sdk
.
onStreamData
(
'
users
'
,
protectedFunction
(
ddpMessage
=>
RocketChat
.
_setUser
(
ddpMessage
)));
this
.
notifyLoggedListener
=
this
.
sdk
.
onStreamData
(
'
stream-notify-logged
'
,
protectedFunction
((
ddpMessage
)
=>
{
...
...
patches/@rocket.chat+sdk+1.0.0-alpha.41.patch
View file @
e5ec5872
diff --git a/node_modules/@rocket.chat/sdk/lib/api/api.js b/node_modules/@rocket.chat/sdk/lib/api/api.js
index 5b7dc21..
49f1af5
100644
index 5b7dc21..
b57b497
100644
--- a/node_modules/@rocket.chat/sdk/lib/api/api.js
+++ b/node_modules/@rocket.chat/sdk/lib/api/api.js
@@ -62,6 +62,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
...
...
@@ -19,8 +19,32 @@ index 5b7dc21..49f1af5 100644
},
set: function (obj) {
this._headers = obj;
@@ -209,6 +210,9 @@
var Api = /** @class */ (function (_super) {
case 11:
err_1 = _b.sent();
this.logger && this.logger.error("[API] POST error(" + endpoint + "): " + JSON.stringify(err_1));
+ if (err_1.status === 401) {
+ this.emit('unauthorized');
+ }
throw err_1;
case 12: return [2 /*return*/];
}
diff --git a/node_modules/@rocket.chat/sdk/lib/clients/Rocketchat.js b/node_modules/@rocket.chat/sdk/lib/clients/Rocketchat.js
index fbbd519..4cbf949 100644
--- a/node_modules/@rocket.chat/sdk/lib/clients/Rocketchat.js
+++ b/node_modules/@rocket.chat/sdk/lib/clients/Rocketchat.js
@@ -122,6 +122,9 @@
var RocketChatClient = /** @class */ (function (_super) {
default:
throw new Error("Invalid Protocol: " + protocol + ", valids: " + Object.keys(drivers_1.Protocols).join());
}
+
+ this.once('unauthorized', async() => (await _this.socket).ddp.emit('unauthorized')); // echo event to sdk
+
return _this;
}
RocketChatClient.prototype.resume = function (_a) {
diff --git a/node_modules/@rocket.chat/sdk/lib/drivers/ddp.js b/node_modules/@rocket.chat/sdk/lib/drivers/ddp.js
index
e3510c7
..e3216cc 100644
index
8f04ff1
..e3216cc 100644
--- a/node_modules/@rocket.chat/sdk/lib/drivers/ddp.js
+++ b/node_modules/@rocket.chat/sdk/lib/drivers/ddp.js
@@ -110,6 +110,7 @@
tiny_events_1.EventEmitter.prototype.removeAllListeners = function (event) {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment