mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-09-07 22:41:57 +00:00
Added M_UNKNOWN_TOKEN error code and send it when there is an unrecognised access_token
This commit is contained in:
parent
d5033849a5
commit
61933f8e52
@ -262,7 +262,10 @@ the error, but the keys 'error' and 'errcode' will always be present.
|
|||||||
Some standard error codes are below:
|
Some standard error codes are below:
|
||||||
|
|
||||||
M_FORBIDDEN:
|
M_FORBIDDEN:
|
||||||
Forbidden access, e.g. bad access token, failed login.
|
Forbidden access, e.g. joining a room without permission, failed login.
|
||||||
|
|
||||||
|
M_UNKNOWN_TOKEN:
|
||||||
|
The access token specified was not recognised.
|
||||||
|
|
||||||
M_BAD_JSON:
|
M_BAD_JSON:
|
||||||
Request contained valid JSON, but it was malformed in some way, e.g. missing
|
Request contained valid JSON, but it was malformed in some way, e.g. missing
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
from synapse.api.constants import Membership
|
from synapse.api.constants import Membership
|
||||||
from synapse.api.errors import AuthError, StoreError
|
from synapse.api.errors import AuthError, StoreError, Codes
|
||||||
from synapse.api.events.room import (RoomTopicEvent, RoomMemberEvent,
|
from synapse.api.events.room import (RoomTopicEvent, RoomMemberEvent,
|
||||||
MessageEvent, FeedbackEvent)
|
MessageEvent, FeedbackEvent)
|
||||||
|
|
||||||
@ -163,4 +163,5 @@ class Auth(object):
|
|||||||
user_id = yield self.store.get_user_by_token(token=token)
|
user_id = yield self.store.get_user_by_token(token=token)
|
||||||
defer.returnValue(self.hs.parse_userid(user_id))
|
defer.returnValue(self.hs.parse_userid(user_id))
|
||||||
except StoreError:
|
except StoreError:
|
||||||
raise AuthError(403, "Unrecognised access token.")
|
raise AuthError(403, "Unrecognised access token.",
|
||||||
|
errcode=Codes.UNKNOWN_TOKEN)
|
||||||
|
@ -27,6 +27,7 @@ class Codes(object):
|
|||||||
BAD_PAGINATION = "M_BAD_PAGINATION"
|
BAD_PAGINATION = "M_BAD_PAGINATION"
|
||||||
UNKNOWN = "M_UNKNOWN"
|
UNKNOWN = "M_UNKNOWN"
|
||||||
NOT_FOUND = "M_NOT_FOUND"
|
NOT_FOUND = "M_NOT_FOUND"
|
||||||
|
UNKNOWN_TOKEN = "M_UNKNOWN_TOKEN"
|
||||||
|
|
||||||
|
|
||||||
class CodeMessageException(Exception):
|
class CodeMessageException(Exception):
|
||||||
|
Loading…
Reference in New Issue
Block a user