Merge pull request #112 from taigaio/bug/1178/403-error-control

fix #1178 - 403 error
stable
Alejandro 2014-10-23 08:50:35 +02:00
commit f30ddeb847
21 changed files with 38 additions and 91 deletions

View File

@ -136,6 +136,8 @@ configure = ($routeProvider, $locationProvider, $httpProvider, $provide, $tgEven
{templateUrl: "/partials/error.html"})
$routeProvider.when("/not-found",
{templateUrl: "/partials/not-found.html"})
$routeProvider.when("/permission-denied",
{templateUrl: "/partials/permission-denied.html"})
$routeProvider.otherwise({redirectTo: '/not-found'})
$locationProvider.html5Mode(true)

View File

@ -22,6 +22,16 @@
class TaigaBase
class TaigaService extends TaigaBase
class TaigaController extends TaigaBase
onInitialDataError: (xhr) =>
if xhr
if xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
else if xhr.status == 403
@location.path(@navUrls.resolve("permission-denied"))
@location.replace()
return @q.reject(xhr)
@.taiga.Base = TaigaBase
@.taiga.Service = TaigaService

View File

@ -58,11 +58,7 @@ class MembershipsController extends mixOf(taiga.Controller, taiga.PageMixin, tai
promise.then =>
@appTitle.set("Membership - " + @scope.project.name)
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
@scope.$on "membersform:new:success", =>
@.loadMembers()

View File

@ -57,11 +57,7 @@ class ProjectProfileController extends mixOf(taiga.Controller, taiga.PageMixin)
promise.then =>
@appTitle.set("Project profile - " + @scope.sectionName + " - " + @scope.project.name)
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
@scope.$on "project:loaded", =>
@appTitle.set("Project profile - " + @scope.sectionName + " - " + @scope.project.name)

View File

@ -57,11 +57,7 @@ class ProjectValuesController extends mixOf(taiga.Controller, taiga.PageMixin)
promise.then () =>
@appTitle.set("Project values - " + @scope.sectionName + " - " + @scope.project.name)
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
@scope.$on("admin:project-values:move", @.moveValue)

View File

@ -58,11 +58,7 @@ class RolesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fil
promise.then () =>
@appTitle.set("Roles - " + @scope.project.name)
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) =>

View File

@ -74,11 +74,7 @@ class BacklogController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.F
tgLoader.pageLoaded()
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
initializeEventHandlers: ->
@scope.$on "usform:bulk:success", =>

View File

@ -46,6 +46,7 @@ urls = {
"home": "/"
"error": "/error"
"not-found": "/not-found"
"permission-denied": "/permission-denied"
"login": "/login"
"forgot-password": "/forgot-password"

View File

@ -62,11 +62,7 @@ class IssueDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
@appTitle.set(@scope.issue.subject + " - " + @scope.project.name)
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
initializeEventHandlers: ->

View File

@ -74,11 +74,7 @@ class IssuesController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
tgLoader.pageLoaded()
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
@scope.$on "issueform:new:success", =>
@analytics.trackEvent("issue", "create", "create issue on issues list", 1)

View File

@ -78,12 +78,7 @@ class KanbanController extends mixOf(taiga.Controller, taiga.PageMixin, taiga.Fi
tgLoader.pageLoaded()
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
initializeEventHandlers: ->
@scope.$on "usform:new:success", =>

View File

@ -53,11 +53,7 @@ class ProjectsController extends taiga.Controller
@scope.$emit("projects:loaded")
@tgLoader.pageLoaded()
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
loadInitialData: ->
return @rs.projects.list().then (projects) =>
@ -96,11 +92,7 @@ class ProjectController extends taiga.Controller
promise.then () =>
@appTitle.set(@scope.project.name)
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
loadInitialData: ->
# Resolve project slug

View File

@ -55,11 +55,7 @@ class SearchController extends mixOf(taiga.Controller, taiga.PageMixin)
promise.then () =>
@appTitle.set("Search")
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
# Search input watcher
@scope.searchTerm = ""

View File

@ -66,11 +66,7 @@ class TaskboardController extends mixOf(taiga.Controller, taiga.PageMixin)
tgLoader.pageLoaded()
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
initializeEventHandlers: ->
# TODO: Reload entire taskboard after create/edit tasks seems

View File

@ -59,11 +59,7 @@ class TaskDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
@appTitle.set(@scope.task.subject + " - " + @scope.project.name)
tgLoader.pageLoaded()
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
initializeEventHandlers: ->
@scope.$on "attachment:create", =>

View File

@ -51,11 +51,7 @@ class UserChangePasswordController extends mixOf(taiga.Controller, taiga.PageMix
promise = @.loadInitialData()
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) =>

View File

@ -49,11 +49,7 @@ class UserSettingsController extends mixOf(taiga.Controller, taiga.PageMixin)
promise = @.loadInitialData()
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) =>

View File

@ -51,11 +51,7 @@ class UserNotificationsController extends mixOf(taiga.Controller, taiga.PageMixi
promise = @.loadInitialData()
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) =>

View File

@ -62,11 +62,7 @@ class UserStoryDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
tgLoader.pageLoaded()
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
initializeEventHandlers: ->
@scope.$on "attachment:create", =>

View File

@ -65,11 +65,7 @@ class WikiDetailController extends mixOf(taiga.Controller, taiga.PageMixin)
tgLoader.pageLoaded()
# On Error
promise.then null, (xhr) =>
if xhr and xhr.status == 404
@location.path(@navUrls.resolve("not-found"))
@location.replace()
return @q.reject(xhr)
promise.then null, @.onInitialDataError.bind(@)
loadProject: ->
return @rs.projects.get(@scope.projectId).then (project) =>

View File

@ -0,0 +1,7 @@
div.error-main
div.error-container
object.logo-svg(type="image/svg+xml", data="/svg/logo.svg")
img(src="/images/logo.png", alt="TAIGA")
h1.logo Permission denied
p.error-text Error 403.
a(href="/", title="") Take me home