Coverage for apps/accounts/local_auth_schemas.py: 100%

47 statements  

« prev     ^ index     » next       coverage.py v7.17.0, created at 2026-11-04 17:24 +0000

1"""Django Ninja schemas for the local (Lumen-native) staff login endpoints.""" 

2 

3from __future__ import annotations 

4 

5from typing import Literal 

6 

7from ninja import Schema 

8 

9from apps.borrower_portal.schemas import BorrowerUserOut 

10 

11 

12class LoginInput(Schema): 

13 email: str 

14 password: str 

15 

16 

17class SessionUserOut(Schema): 

18 id: int 

19 name: str 

20 role: str 

21 

22 

23class LoginResultOut(Schema): 

24 token: str 

25 # A staff session user, or the borrower portal's BorrowerUser when a borrower signs in 

26 # (add-borrower-portal-api design.md D4). The two shapes share no required-field set, so 

27 # each payload matches exactly one. 

28 user: SessionUserOut | BorrowerUserOut 

29 

30 

31class ProfileOut(Schema): 

32 id: int 

33 name: str 

34 email: str 

35 phone: str | None = None 

36 title: str | None = None 

37 nmls_id: str | None = None 

38 signature: str | None = None 

39 notify: dict 

40 role: str 

41 

42 

43class ProfilePatch(Schema): 

44 name: str | None = None 

45 email: str | None = None 

46 phone: str | None = None 

47 title: str | None = None 

48 nmls_id: str | None = None 

49 signature: str | None = None 

50 notify: dict | None = None 

51 

52 

53class PasswordChangeInput(Schema): 

54 current: str 

55 next: str 

56 

57 

58class ForgotPasswordInput(Schema): 

59 email: str 

60 # Which app's "Forgot password" was used: only that app's reset link is emailed. Left out, 

61 # every account with the email gets its own link (older clients). 

62 app: Literal["staff", "borrower"] | None = None 

63 

64 

65class ForgotPasswordOut(Schema): 

66 sent: bool 

67 # Development only: the reset link that was "emailed" to a borrower account. 

68 devResetLink: str | None = None 

69 

70 

71class ActAsCandidateOut(Schema): 

72 id: int 

73 name: str 

74 role: str 

75 

76 

77class ActAsInput(Schema): 

78 target_user_id: int