|
@@ -7,6 +7,7 @@ from sqlalchemy.orm.exc import NoResultFound
|
7
|
7
|
|
8
|
8
|
|
9
|
9
|
from tracim.exceptions import NotAuthentificated
|
|
10
|
+from tracim.exceptions import UserNotFoundInTracimRequest
|
10
|
11
|
from tracim.exceptions import UserDoesNotExist
|
11
|
12
|
from tracim.exceptions import WorkspaceNotFound
|
12
|
13
|
from tracim.exceptions import ImmutableAttribute
|
|
@@ -144,10 +145,10 @@ def get_candidate_user(
|
144
|
145
|
if 'user_id' in request.matchdict:
|
145
|
146
|
login = request.matchdict['user_id']
|
146
|
147
|
if not login:
|
147
|
|
- raise UserDoesNotExist('no user_id found, incorrect request ?')
|
|
148
|
+ raise UserNotFoundInTracimRequest('You request a candidate user but the context not permit to found one') # nopep8
|
148
|
149
|
user = uapi.get_one(login)
|
149
|
|
- except NoResultFound:
|
150
|
|
- raise NotAuthentificated('User not found')
|
|
150
|
+ except UserNotFoundInTracimRequest as exc:
|
|
151
|
+ raise UserDoesNotExist('User {} not found'.format(login)) from exc
|
151
|
152
|
return user
|
152
|
153
|
|
153
|
154
|
|
|
@@ -164,11 +165,10 @@ def get_auth_safe_user(
|
164
|
165
|
try:
|
165
|
166
|
login = request.authenticated_userid
|
166
|
167
|
if not login:
|
167
|
|
- raise NotAuthentificated('not authenticated user_id,'
|
168
|
|
- 'Failed Authentification ?')
|
|
168
|
+ raise UserNotFoundInTracimRequest('You request a current user but the context not permit to found one') # nopep8
|
169
|
169
|
user = uapi.get_one_by_email(login)
|
170
|
|
- except NoResultFound:
|
171
|
|
- raise NotAuthentificated('User not found')
|
|
170
|
+ except (UserDoesNotExist, UserNotFoundInTracimRequest) as exc:
|
|
171
|
+ raise NotAuthentificated('User {} not found'.format(login)) from exc
|
172
|
172
|
return user
|
173
|
173
|
|
174
|
174
|
|