Errors::Authorization.
This commit is contained in:
parent
a506fced0d
commit
761c12a0ba
@ -12,7 +12,7 @@ class FileStorage::Request
|
|||||||
def handle(filestoraged : FileStorage::Service, event : IPC::Event::Events)
|
def handle(filestoraged : FileStorage::Service, event : IPC::Event::Events)
|
||||||
user = filestoraged.get_logged_user event
|
user = filestoraged.get_logged_user event
|
||||||
|
|
||||||
raise Exception.new "unauthorized" if user.nil?
|
return Errors::Authorization.new @mid if user.nil?
|
||||||
|
|
||||||
# FIXME: Maybe this should be moved to FileStorage::Service
|
# FIXME: Maybe this should be moved to FileStorage::Service
|
||||||
fd = event.connection.fd
|
fd = event.connection.fd
|
||||||
@ -35,4 +35,3 @@ class FileStorage::Response
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -7,8 +7,16 @@ class FileStorage::Errors
|
|||||||
end
|
end
|
||||||
FileStorage.errors << GenericError
|
FileStorage.errors << GenericError
|
||||||
|
|
||||||
|
JSONIPC.request Authorization, 201 do
|
||||||
|
property mid : String
|
||||||
|
property reason : String
|
||||||
|
def initialize(@mid, @reason = "authorization")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
FileStorage.errors << Authorization
|
||||||
|
|
||||||
# When uploading a chunk already present in the DB.
|
# When uploading a chunk already present in the DB.
|
||||||
JSONIPC.request ChunkAlreadyUploaded, 201 do
|
JSONIPC.request ChunkAlreadyUploaded, 202 do
|
||||||
property mid : String
|
property mid : String
|
||||||
property reason = "Chunk already present"
|
property reason = "Chunk already present"
|
||||||
property filedigest : String
|
property filedigest : String
|
||||||
@ -20,7 +28,7 @@ class FileStorage::Errors
|
|||||||
FileStorage.errors << ChunkAlreadyUploaded
|
FileStorage.errors << ChunkAlreadyUploaded
|
||||||
|
|
||||||
# You upload a chunk, but you are not the owner of the file.
|
# You upload a chunk, but you are not the owner of the file.
|
||||||
JSONIPC.request ChunkUploadDenied, 202 do
|
JSONIPC.request ChunkUploadDenied, 203 do
|
||||||
property mid : String
|
property mid : String
|
||||||
property reason = "This file is not yours"
|
property reason = "This file is not yours"
|
||||||
property filedigest : String
|
property filedigest : String
|
||||||
@ -31,7 +39,7 @@ class FileStorage::Errors
|
|||||||
FileStorage.errors << ChunkUploadDenied
|
FileStorage.errors << ChunkUploadDenied
|
||||||
|
|
||||||
# When uploading a file already present in the DB.
|
# When uploading a file already present in the DB.
|
||||||
JSONIPC.request FileExists, 203 do
|
JSONIPC.request FileExists, 204 do
|
||||||
property mid : String
|
property mid : String
|
||||||
property reason = "file already present"
|
property reason = "file already present"
|
||||||
property filedigest : String
|
property filedigest : String
|
||||||
@ -42,7 +50,7 @@ class FileStorage::Errors
|
|||||||
FileStorage.errors << FileExists
|
FileStorage.errors << FileExists
|
||||||
|
|
||||||
# When transfering a chunk for an inexistent file.
|
# When transfering a chunk for an inexistent file.
|
||||||
JSONIPC.request FileDoesNotExist, 204 do
|
JSONIPC.request FileDoesNotExist, 205 do
|
||||||
property mid : String
|
property mid : String
|
||||||
property reason = "file does not exist"
|
property reason = "file does not exist"
|
||||||
property filedigest : String
|
property filedigest : String
|
||||||
|
@ -20,7 +20,7 @@ class FileStorage::Request
|
|||||||
def handle(filestoraged : FileStorage::Service, event : IPC::Event::Events)
|
def handle(filestoraged : FileStorage::Service, event : IPC::Event::Events)
|
||||||
user = filestoraged.get_logged_user event
|
user = filestoraged.get_logged_user event
|
||||||
|
|
||||||
raise Exception.new "unauthorized" if user.nil?
|
return Errors::Authorization.new @mid if user.nil?
|
||||||
|
|
||||||
# FIXME: Maybe this should be moved to FileStorage::Service
|
# FIXME: Maybe this should be moved to FileStorage::Service
|
||||||
fd = event.connection.fd
|
fd = event.connection.fd
|
||||||
@ -46,7 +46,7 @@ class FileStorage::Request
|
|||||||
def handle(filestoraged : FileStorage::Service, event : IPC::Event::Events)
|
def handle(filestoraged : FileStorage::Service, event : IPC::Event::Events)
|
||||||
user = filestoraged.get_logged_user event
|
user = filestoraged.get_logged_user event
|
||||||
|
|
||||||
raise Exception.new "unauthorized" if user.nil?
|
return Errors::Authorization.new @mid if user.nil?
|
||||||
|
|
||||||
# FIXME: Maybe this should be moved to FileStorage::Service
|
# FIXME: Maybe this should be moved to FileStorage::Service
|
||||||
fd = event.connection.fd
|
fd = event.connection.fd
|
||||||
|
@ -10,7 +10,7 @@ class FileStorage::Request
|
|||||||
def handle(filestoraged : FileStorage::Service, event : IPC::Event::Events)
|
def handle(filestoraged : FileStorage::Service, event : IPC::Event::Events)
|
||||||
user = filestoraged.get_logged_user event
|
user = filestoraged.get_logged_user event
|
||||||
|
|
||||||
raise Exception.new "unauthorized" if user.nil?
|
return Errors::Authorization.new @mid if user.nil?
|
||||||
|
|
||||||
# FIXME: Maybe this should be moved to FileStorage::Service
|
# FIXME: Maybe this should be moved to FileStorage::Service
|
||||||
fd = event.connection.fd
|
fd = event.connection.fd
|
||||||
|
Loading…
Reference in New Issue
Block a user