Просмотр исходного кода

[misc] re-level log: 403 from web goes to WARN and emit 'not authorized'

Users will get redirected to the login page and will see a 'restricted'
 page after logging in again.
See frontend: ConnectionManager.reportConnectionError
Jakob Ackermann 6 лет назад
Родитель
Сommit
884b340c75

+ 3 - 0
services/real-time/app/js/WebApiManager.js

@@ -8,6 +8,7 @@ const logger = require('logger-sharelatex')
 const {
   CodedError,
   CorruptedJoinProjectResponseError,
+  NotAuthorizedError,
   WebApiRequestFailedError
 } = require('./Errors')
 
@@ -56,6 +57,8 @@ module.exports = {
               'TooManyRequests'
             )
           )
+        } else if (response.statusCode === 403) {
+          callback(new NotAuthorizedError())
         } else {
           callback(new WebApiRequestFailedError(response.statusCode))
         }

+ 1 - 3
services/real-time/test/acceptance/js/JoinProjectTests.js

@@ -221,9 +221,7 @@ describe('joinProject', function () {
     })
 
     it('should return an error', function () {
-      this.error.message.should.equal(
-        'Something went wrong in real-time service'
-      )
+      this.error.message.should.equal('not authorized')
     })
 
     it('should not have joined the project room', function (done) {

+ 1 - 2
services/real-time/test/unit/js/WebApiManagerTests.js

@@ -107,8 +107,7 @@ describe('WebApiManager', function () {
         this.callback
           .calledWith(
             sinon.match({
-              message: 'non-success status code from web',
-              info: { statusCode: 403 }
+              message: 'not authorized'
             })
           )
           .should.equal(true)