mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
redirect to login if session expired in file upload
This commit is contained in:
parent
9383977ca5
commit
25411189a7
2 changed files with 24 additions and 2 deletions
|
@ -357,6 +357,7 @@ script(type="text/ng-template", id="uploadFileModalTemplate")
|
|||
span
|
||||
.alert.alert-warning.small(ng-if="tooManyFiles") #{translate("maximum_files_uploaded_together", {max:"{{max_files}}"})}
|
||||
.alert.alert-warning.small(ng-if="rateLimitHit") #{translate("too_many_files_uploaded_throttled_short_period")}
|
||||
.alert.alert-warning.small(ng-if="notLoggedIn") #{translate("session_expired_redirecting_to_login", {seconds:"{{secondsToRedirect}}"})}
|
||||
|
||||
.modal-body(
|
||||
fine-upload
|
||||
|
|
|
@ -99,11 +99,28 @@ define [
|
|||
]
|
||||
|
||||
App.controller "UploadFileModalController", [
|
||||
"$scope", "ide", "$modalInstance", "$timeout", "parent_folder",
|
||||
($scope, ide, $modalInstance, $timeout, parent_folder) ->
|
||||
"$scope", "ide", "$modalInstance", "$timeout", "parent_folder", "$window"
|
||||
($scope, ide, $modalInstance, $timeout, parent_folder, $window) ->
|
||||
$scope.parent_folder_id = parent_folder?.id
|
||||
$scope.tooManyFiles = false
|
||||
$scope.rateLimitHit = false
|
||||
$scope.secondsToRedirect = 10
|
||||
$scope.notLoggedIn = false
|
||||
|
||||
|
||||
needToLogBackIn = ->
|
||||
$scope.notLoggedIn = true
|
||||
decreseTimeout = ->
|
||||
$timeout (() ->
|
||||
if $scope.secondsToRedirect == 0
|
||||
$window.location.href = "/login?redir=/project/#{ide.project_id}"
|
||||
else
|
||||
decreseTimeout()
|
||||
$scope.secondsToRedirect = $scope.secondsToRedirect - 1
|
||||
), 1000
|
||||
|
||||
decreseTimeout()
|
||||
|
||||
|
||||
uploadCount = 0
|
||||
$scope.onUpload = () ->
|
||||
|
@ -127,8 +144,12 @@ define [
|
|||
return true
|
||||
|
||||
$scope.onError = (id, name, reason)->
|
||||
console.log(id, name, reason)
|
||||
if reason.indexOf("429") != -1
|
||||
$scope.rateLimitHit = true
|
||||
else if reason.indexOf("403") != -1
|
||||
needToLogBackIn()
|
||||
|
||||
|
||||
$scope.cancel = () ->
|
||||
$modalInstance.dismiss('cancel')
|
||||
|
|
Loading…
Reference in a new issue