File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111from ninja .schema import DjangoGetter
1212from ninja_extra import service_resolver
1313from ninja_extra .context import RouteContext
14- from pydantic import ConfigDict , ValidationInfo , model_validator
14+ from pydantic import ConfigDict , SecretStr , ValidationInfo , model_validator
1515from pydantic .main import BaseModel
1616
1717import ninja_jwt .exceptions as exceptions
@@ -126,6 +126,8 @@ def get_token(cls, user: AbstractUser) -> Dict:
126126
127127
128128class TokenObtainInputSchemaBase (ModelSchema , TokenInputSchemaMixin ):
129+ password : SecretStr
130+
129131 class Meta :
130132 # extra = "forbid"
131133 model = get_user_model ()
@@ -147,6 +149,9 @@ def post_validate(self, info: ValidationInfo) -> BaseModel:
147149 )
148150
149151 credentials = schema_input .get_values ()
152+ password : SecretStr = credentials .pop ("password" )
153+ if password and isinstance (password , SecretStr ):
154+ credentials ["password" ] = password .get_secret_value ()
150155 request = schema_input .get_request ()
151156
152157 self .authenticate (request , credentials )
You can’t perform that action at this time.
0 commit comments