浏览代码

Inline exceptions for controller

Guénaël Muller 7 年前
父节点
当前提交
cf5044dfd1
共有 1 个文件被更改,包括 5 次插入16 次删除
  1. 5 16
      tracim/views/core_api/session_controller.py

+ 5 - 16
tracim/views/core_api/session_controller.py 查看文件

33
     @hapic.with_api_doc()
33
     @hapic.with_api_doc()
34
     @hapic.input_headers(LoginOutputHeaders())
34
     @hapic.input_headers(LoginOutputHeaders())
35
     @hapic.input_body(BasicAuthSchema())
35
     @hapic.input_body(BasicAuthSchema())
36
-    @hapic.handle_exception(AuthenticationFailed, http_code=HTTPStatus.BAD_REQUEST)
36
+    @hapic.handle_exception(AuthenticationFailed, HTTPStatus.BAD_REQUEST)
37
     # TODO - G.M - 17-04-2018 - fix output header ?
37
     # TODO - G.M - 17-04-2018 - fix output header ?
38
     # @hapic.output_headers()
38
     # @hapic.output_headers()
39
-    @hapic.output_body(
40
-        NoContentSchema(),
41
-        default_http_code=HTTPStatus.NO_CONTENT
42
-    )
39
+    @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)
43
     def login(self, context, request: TracimRequest, hapic_data=None):
40
     def login(self, context, request: TracimRequest, hapic_data=None):
44
         """
41
         """
45
         Logs user into the system
42
         Logs user into the system
55
         return uapi.authenticate_user(email, password)
52
         return uapi.authenticate_user(email, password)
56
 
53
 
57
     @hapic.with_api_doc()
54
     @hapic.with_api_doc()
58
-    @hapic.output_body(
59
-        NoContentSchema(),
60
-        default_http_code=HTTPStatus.NO_CONTENT
61
-    )
55
+    @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)
62
     def logout(self, context, request: TracimRequest, hapic_data=None):
56
     def logout(self, context, request: TracimRequest, hapic_data=None):
63
         """
57
         """
64
         Logs out current logged in user session
58
         Logs out current logged in user session
67
         return
61
         return
68
 
62
 
69
     @hapic.with_api_doc()
63
     @hapic.with_api_doc()
70
-    @hapic.handle_exception(
71
-        NotAuthentificated,
72
-        http_code=HTTPStatus.UNAUTHORIZED
73
-    )
74
-    @hapic.output_body(
75
-        UserSchema(),
76
-    )
64
+    @hapic.handle_exception(NotAuthentificated, HTTPStatus.UNAUTHORIZED)
65
+    @hapic.output_body(UserSchema(),)
77
     def whoami(self, context, request: TracimRequest, hapic_data=None):
66
     def whoami(self, context, request: TracimRequest, hapic_data=None):
78
         """
67
         """
79
         Return current logged in user or 401
68
         Return current logged in user or 401