From a9e61c5d8b876f69c6e80157b46043ec2a86ba3b Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Thu, 20 Feb 2020 09:58:13 -0300 Subject: [PATCH] [FIX] HTTP Basic Auth (#1753) Co-authored-by: Diego Mello --- .../__snapshots__/Storyshots.test.js.snap | 95 +++++++++++++++++++ app/containers/Avatar.js | 2 + app/lib/methods/actions.js | 1 + app/lib/methods/sendFileMessage.js | 7 +- app/lib/rocketchat.js | 7 +- app/sagas/selectServer.js | 4 + app/utils/fetch.js | 22 ++++- app/views/NewServerView.js | 26 ++++- package.json | 1 + yarn.lock | 2 +- 10 files changed, 156 insertions(+), 11 deletions(-) diff --git a/__tests__/__snapshots__/Storyshots.test.js.snap b/__tests__/__snapshots__/Storyshots.test.js.snap index ed7afaf9e..2b7408527 100644 --- a/__tests__/__snapshots__/Storyshots.test.js.snap +++ b/__tests__/__snapshots__/Storyshots.test.js.snap @@ -118,6 +118,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -360,6 +361,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -602,6 +604,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -822,6 +825,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -1230,6 +1234,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -1588,6 +1593,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -1826,6 +1832,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -2086,6 +2093,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -2328,6 +2336,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -2580,6 +2589,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -2892,6 +2902,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -3340,6 +3351,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -3704,6 +3716,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -4124,6 +4137,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://pbs.twimg.com/profile_images/1016397063649660929/14EIApTi_400x400.jpg", } @@ -4366,6 +4380,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -4608,6 +4623,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -5013,6 +5029,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -5260,6 +5277,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -5507,6 +5525,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -5881,6 +5900,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -6129,6 +6149,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -6408,6 +6429,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -6708,6 +6730,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -6950,6 +6973,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -7532,6 +7556,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -8555,6 +8580,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/rocket.cat?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -8775,6 +8801,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -8995,6 +9022,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/rocket.cat?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -9215,6 +9243,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -9457,6 +9486,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/rocket.cat?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -9739,6 +9769,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -10098,6 +10129,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/rocket.cat?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -10363,6 +10395,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -10605,6 +10638,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -10902,6 +10936,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -11253,6 +11288,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -11547,6 +11583,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -11795,6 +11832,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -12885,6 +12923,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -13277,6 +13316,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -13723,6 +13763,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -14141,6 +14182,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -14625,6 +14667,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -14940,6 +14983,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -15343,6 +15387,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -15615,6 +15660,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -15887,6 +15933,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -16159,6 +16206,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -16431,6 +16479,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -16671,6 +16720,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -16911,6 +16961,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -17074,6 +17125,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -17394,6 +17446,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -17583,6 +17636,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -17740,6 +17794,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -17991,6 +18046,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -18180,6 +18236,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -18353,6 +18410,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -18510,6 +18568,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -18673,6 +18732,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -18988,6 +19048,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -19305,6 +19366,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -19622,6 +19684,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -19961,6 +20024,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -20321,6 +20385,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -20796,6 +20861,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -21408,6 +21474,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -22102,6 +22169,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -22426,6 +22494,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -22651,6 +22720,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -23122,6 +23192,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -23370,6 +23441,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -23617,6 +23689,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -23784,6 +23857,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -23951,6 +24025,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -24118,6 +24193,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -24285,6 +24361,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -24452,6 +24529,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -24619,6 +24697,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -24786,6 +24865,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -24953,6 +25033,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -25120,6 +25201,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -25287,6 +25369,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -25454,6 +25537,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -25621,6 +25705,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -25788,6 +25873,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -25955,6 +26041,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -26122,6 +26209,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -26364,6 +26452,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -26913,6 +27002,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -27333,6 +27423,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -27829,6 +27920,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -28059,6 +28151,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -28406,6 +28499,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } @@ -28680,6 +28774,7 @@ exports[`Storyshots Message list message 1`] = ` resizeMode="cover" source={ Object { + "headers": Object {}, "priority": "high", "uri": "https://open.rocket.chat/avatar/diego.mello?format=png&width=50&height=50&rc_token=79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz&rc_uid=y8bd77ptZswPj3EW8", } diff --git a/app/containers/Avatar.js b/app/containers/Avatar.js index 39d488efa..c951fd23f 100644 --- a/app/containers/Avatar.js +++ b/app/containers/Avatar.js @@ -2,6 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { View } from 'react-native'; import FastImage from 'react-native-fast-image'; +import { settings as RocketChatSettings } from '@rocket.chat/sdk'; import Touch from '../utils/touch'; const formatUrl = (url, baseUrl, uriSize, avatarAuthURLFragment) => ( @@ -45,6 +46,7 @@ const Avatar = React.memo(({ style={avatarStyle} source={{ uri, + headers: RocketChatSettings.customHeaders, priority: FastImage.priority.high }} /> diff --git a/app/lib/methods/actions.js b/app/lib/methods/actions.js index 5bd7e1073..65cae1a57 100644 --- a/app/lib/methods/actions.js +++ b/app/lib/methods/actions.js @@ -1,5 +1,6 @@ import random from '../../utils/random'; import EventEmitter from '../../utils/events'; +import fetch from '../../utils/fetch'; import Navigation from '../Navigation'; const ACTION_TYPES = { diff --git a/app/lib/methods/sendFileMessage.js b/app/lib/methods/sendFileMessage.js index 6297d645f..b5a85c4cc 100644 --- a/app/lib/methods/sendFileMessage.js +++ b/app/lib/methods/sendFileMessage.js @@ -1,8 +1,8 @@ import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; +import { settings as RocketChatSettings } from '@rocket.chat/sdk'; import database from '../database'; import log from '../../utils/log'; -import { headers } from '../../utils/fetch'; const uploadQueue = {}; @@ -75,7 +75,10 @@ export function sendFileMessage(rid, fileInfo, tmid, server, user) { xhr.setRequestHeader('X-Auth-Token', token); xhr.setRequestHeader('X-User-Id', id); - xhr.setRequestHeader('User-Agent', headers['User-Agent']); + const { customHeaders } = RocketChatSettings; + Object.keys(customHeaders).forEach((key) => { + xhr.setRequestHeader(key, customHeaders[key]); + }); xhr.upload.onprogress = async({ total, loaded }) => { try { diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 634cbb812..4d5de613c 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -1,6 +1,6 @@ import { AsyncStorage, InteractionManager } from 'react-native'; import semver from 'semver'; -import { Rocketchat as RocketchatClient, settings as RocketChatSettings } from '@rocket.chat/sdk'; +import { Rocketchat as RocketchatClient } from '@rocket.chat/sdk'; import RNUserDefaults from 'rn-user-defaults'; import { Q } from '@nozbe/watermelondb'; import * as FileSystem from 'expo-file-system'; @@ -12,7 +12,7 @@ import database from './database'; import log from '../utils/log'; import { isIOS, getBundleId } from '../utils/deviceInfo'; import { extractHostname } from '../utils/server'; -import fetch, { headers } from '../utils/fetch'; +import fetch, { BASIC_AUTH_KEY } from '../utils/fetch'; import { setUser, setLoginServices, loginRequest } from '../actions/login'; import { disconnect, connectSuccess, connectRequest } from '../actions/connect'; @@ -58,8 +58,6 @@ const MIN_ROCKETCHAT_VERSION = '0.70.0'; const STATUSES = ['offline', 'online', 'away', 'busy']; -RocketChatSettings.customHeaders = headers; - const RocketChat = { TOKEN_KEY, callJitsi, @@ -446,6 +444,7 @@ const RocketChat = { await RNUserDefaults.clear('currentServer'); await RNUserDefaults.clear(TOKEN_KEY); await RNUserDefaults.clear(`${ TOKEN_KEY }-${ server }`); + await RNUserDefaults.clear(`${ BASIC_AUTH_KEY }-${ server }`); try { const db = database.active; diff --git a/app/sagas/selectServer.js b/app/sagas/selectServer.js index 0fd9938fe..5cfa51ad2 100644 --- a/app/sagas/selectServer.js +++ b/app/sagas/selectServer.js @@ -19,6 +19,7 @@ import log from '../utils/log'; import { extractHostname } from '../utils/server'; import I18n from '../i18n'; import { SERVERS, TOKEN, SERVER_URL } from '../constants/userDefaults'; +import { BASIC_AUTH_KEY, setBasicAuth } from '../utils/fetch'; const getServerInfo = function* getServerInfo({ server, raiseError = true }) { try { @@ -89,6 +90,9 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch } } + const basicAuth = yield RNUserDefaults.get(`${ BASIC_AUTH_KEY }-${ server }`); + setBasicAuth(basicAuth); + if (user) { yield RocketChat.connect({ server, user, logoutOnError: true }); yield put(setUser(user)); diff --git a/app/utils/fetch.js b/app/utils/fetch.js index ec80dd02c..b29c02fc4 100644 --- a/app/utils/fetch.js +++ b/app/utils/fetch.js @@ -1,13 +1,29 @@ import { Platform } from 'react-native'; import DeviceInfo from 'react-native-device-info'; +import { settings as RocketChatSettings } from '@rocket.chat/sdk'; // this form is required by Rocket.Chat's parser in "app/statistics/server/lib/UAParserCustom.js" -export const headers = { 'User-Agent': `RC Mobile; ${ Platform.OS } ${ DeviceInfo.getSystemVersion() }; v${ DeviceInfo.getVersion() } (${ DeviceInfo.getBuildNumber() })` }; +export const headers = { + 'User-Agent': `RC Mobile; ${ Platform.OS } ${ DeviceInfo.getSystemVersion() }; v${ DeviceInfo.getVersion() } (${ DeviceInfo.getBuildNumber() })` +}; + +let _basicAuth; +export const setBasicAuth = (basicAuth) => { + _basicAuth = basicAuth; + if (basicAuth) { + RocketChatSettings.customHeaders = { ...RocketChatSettings.customHeaders, Authorization: `Basic ${ _basicAuth }` }; + } else { + RocketChatSettings.customHeaders = headers; + } +}; +export const BASIC_AUTH_KEY = 'BASIC_AUTH_KEY'; + +RocketChatSettings.customHeaders = headers; export default (url, options = {}) => { - let customOptions = { ...options, headers }; + let customOptions = { ...options, headers: RocketChatSettings.customHeaders }; if (options && options.headers) { - customOptions = { ...customOptions, headers: { ...options.headers, ...headers } }; + customOptions = { ...customOptions, headers: { ...options.headers, ...customOptions.headers } }; } return fetch(url, customOptions); }; diff --git a/app/views/NewServerView.js b/app/views/NewServerView.js index 37c7cf7bf..d339ac315 100644 --- a/app/views/NewServerView.js +++ b/app/views/NewServerView.js @@ -9,6 +9,9 @@ import * as FileSystem from 'expo-file-system'; import DocumentPicker from 'react-native-document-picker'; import ActionSheet from 'react-native-action-sheet'; import isEqual from 'deep-equal'; +import RNUserDefaults from 'rn-user-defaults'; +import { encode } from 'base-64'; +import parse from 'url-parse'; import { serverRequest } from '../actions/server'; import sharedStyles from './Styles'; @@ -25,6 +28,7 @@ import { themes } from '../constants/colors'; import log from '../utils/log'; import { animateNextTransition } from '../utils/layoutAnimation'; import { withTheme } from '../theme'; +import { setBasicAuth, BASIC_AUTH_KEY } from '../utils/fetch'; const styles = StyleSheet.create({ image: { @@ -148,7 +152,22 @@ class NewServerView extends React.Component { if (text) { Keyboard.dismiss(); - connectServer(this.completeUrl(text), cert); + const server = this.completeUrl(text); + await this.basicAuth(server, text); + connectServer(server, cert); + } + } + + basicAuth = async(server, text) => { + try { + const parsedUrl = parse(text, true); + if (parsedUrl.auth.length) { + const credentials = encode(parsedUrl.auth); + await RNUserDefaults.set(`${ BASIC_AUTH_KEY }-${ server }`, credentials); + setBasicAuth(credentials); + } + } catch { + // do nothing } } @@ -177,6 +196,11 @@ class NewServerView extends React.Component { } completeUrl = (url) => { + const parsedUrl = parse(url, true); + if (parsedUrl.auth.length) { + url = parsedUrl.host; + } + url = url && url.replace(/\s/g, ''); if (/^(\w|[0-9-_]){3,}$/.test(url) diff --git a/package.json b/package.json index 0fa4aeed9..fbf95bbcc 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "@react-native-community/slider": "2.0.5", "@rocket.chat/sdk": "1.0.0-alpha.41", "@rocket.chat/ui-kit": "^0.2.0-alpha.25", + "base-64": "^0.1.0", "bugsnag-react-native": "2.23.2", "commonmark": "git+https://github.com/RocketChat/commonmark.js.git", "commonmark-react-renderer": "git+https://github.com/RocketChat/commonmark-react-renderer.git", diff --git a/yarn.lock b/yarn.lock index 5891687ef..51d8a196f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2748,7 +2748,7 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= -base-64@0.1.0: +base-64@0.1.0, base-64@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/base-64/-/base-64-0.1.0.tgz#780a99c84e7d600260361511c4877613bf24f6bb" integrity sha1-eAqZyE59YAJgNhURxId2E78k9rs=