66
77from typing import Any
88
9- from _common import Error , Log
109from fastapi import APIRouter , status
1110from models_library .api_schemas_webserver .auth import (
1211 AccountRequestInfo ,
1514 UnregisterCheck ,
1615)
1716from models_library .generics import Envelope
17+ from models_library .rest_error import EnvelopedError , Log
1818from pydantic import BaseModel , Field , confloat
1919from simcore_service_webserver ._meta import API_VTAG
2020from simcore_service_webserver .login ._2fa_handlers import Resend2faBody
@@ -75,7 +75,7 @@ async def register(_body: RegisterBody):
7575 "/auth/unregister" ,
7676 response_model = Envelope [Log ],
7777 status_code = status .HTTP_200_OK ,
78- responses = {status .HTTP_409_CONFLICT : {"model" : Envelope [ Error ] }},
78+ responses = {status .HTTP_409_CONFLICT : {"model" : EnvelopedError }},
7979)
8080async def unregister_account (_body : UnregisterCheck ):
8181 ...
@@ -107,7 +107,7 @@ async def phone_confirmation(_body: PhoneConfirmationBody):
107107 responses = {
108108 # status.HTTP_503_SERVICE_UNAVAILABLE
109109 status .HTTP_401_UNAUTHORIZED : {
110- "model" : Envelope [ Error ] ,
110+ "model" : EnvelopedError ,
111111 "description" : "unauthorized reset due to invalid token code" ,
112112 }
113113 },
@@ -122,7 +122,7 @@ async def login(_body: LoginBody):
122122 operation_id = "auth_login_2fa" ,
123123 responses = {
124124 status .HTTP_401_UNAUTHORIZED : {
125- "model" : Envelope [ Error ] ,
125+ "model" : EnvelopedError ,
126126 "description" : "unauthorized reset due to invalid token code" ,
127127 }
128128 },
@@ -137,7 +137,7 @@ async def login_2fa(_body: LoginTwoFactorAuthBody):
137137 operation_id = "auth_resend_2fa_code" ,
138138 responses = {
139139 status .HTTP_401_UNAUTHORIZED : {
140- "model" : Envelope [ Error ] ,
140+ "model" : EnvelopedError ,
141141 "description" : "unauthorized reset due to invalid token code" ,
142142 }
143143 },
@@ -161,7 +161,7 @@ async def logout(_body: LogoutBody):
161161 status_code = status .HTTP_204_NO_CONTENT ,
162162 responses = {
163163 status .HTTP_401_UNAUTHORIZED : {
164- "model" : Envelope [ Error ] ,
164+ "model" : EnvelopedError ,
165165 "description" : "unauthorized reset due to invalid token code" ,
166166 }
167167 },
@@ -174,7 +174,7 @@ async def check_auth():
174174 "/auth/reset-password" ,
175175 response_model = Envelope [Log ],
176176 operation_id = "auth_reset_password" ,
177- responses = {status .HTTP_503_SERVICE_UNAVAILABLE : {"model" : Envelope [ Error ] }},
177+ responses = {status .HTTP_503_SERVICE_UNAVAILABLE : {"model" : EnvelopedError }},
178178)
179179async def reset_password (_body : ResetPasswordBody ):
180180 """a non logged-in user requests a password reset"""
@@ -186,7 +186,7 @@ async def reset_password(_body: ResetPasswordBody):
186186 operation_id = "auth_reset_password_allowed" ,
187187 responses = {
188188 status .HTTP_401_UNAUTHORIZED : {
189- "model" : Envelope [ Error ] ,
189+ "model" : EnvelopedError ,
190190 "description" : "unauthorized reset due to invalid token code" ,
191191 }
192192 },
@@ -201,11 +201,11 @@ async def reset_password_allowed(code: str, _body: ResetPasswordConfirmation):
201201 operation_id = "auth_change_email" ,
202202 responses = {
203203 status .HTTP_401_UNAUTHORIZED : {
204- "model" : Envelope [ Error ] ,
204+ "model" : EnvelopedError ,
205205 "description" : "unauthorized user. Login required" ,
206206 },
207207 status .HTTP_503_SERVICE_UNAVAILABLE : {
208- "model" : Envelope [ Error ] ,
208+ "model" : EnvelopedError ,
209209 "description" : "unable to send confirmation email" ,
210210 },
211211 },
@@ -233,15 +233,15 @@ class PasswordCheckSchema(BaseModel):
233233 operation_id = "auth_change_password" ,
234234 responses = {
235235 status .HTTP_401_UNAUTHORIZED : {
236- "model" : Envelope [ Error ] ,
236+ "model" : EnvelopedError ,
237237 "description" : "unauthorized user. Login required" ,
238238 },
239239 status .HTTP_409_CONFLICT : {
240- "model" : Envelope [ Error ] ,
240+ "model" : EnvelopedError ,
241241 "description" : "mismatch between new and confirmation passwords" ,
242242 },
243243 status .HTTP_422_UNPROCESSABLE_ENTITY : {
244- "model" : Envelope [ Error ] ,
244+ "model" : EnvelopedError ,
245245 "description" : "current password is invalid" ,
246246 },
247247 },
0 commit comments