v3-sessions.yaml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-sessions.yaml
  2. post:
  3. summary: 登录
  4. tags:
  5. - sessions
  6. operationId: post_api_v3_sessions
  7. description: |-
  8. 用用户名或邮箱 + 密码换取 bearer token,同时返回当前用户资料,前端不必再查一次。
  9. 账号或密码不对返回 422(errors.login),不区分是哪一个错。
  10. 按 IP 与账号限流,超出返回 429。
  11. 实现:`V3\SessionController@store`
  12. security:
  13. - { }
  14. -
  15. bearerAuth: []
  16. requestBody:
  17. required: true
  18. content:
  19. application/json:
  20. schema:
  21. type: object
  22. properties:
  23. login:
  24. type: string
  25. description: 用户名或邮箱(邮箱不区分大小写)
  26. password:
  27. type: string
  28. description: 密码
  29. required:
  30. - login
  31. - password
  32. responses:
  33. 200:
  34. description: 成功
  35. content:
  36. application/json:
  37. schema:
  38. type: object
  39. properties:
  40. data:
  41. type: object
  42. properties:
  43. token:
  44. type: string
  45. user:
  46. type: object
  47. properties:
  48. id: { type: string }
  49. nickName: { type: string }
  50. userName: { type: string }
  51. realName: { type: string }
  52. sn: { type: integer }
  53. avatar: { type: string, nullable: true }
  54. roles: { type: array, items: { type: string } }
  55. email: { type: string }
  56. 201:
  57. description: 登录成功
  58. content:
  59. application/json:
  60. schema:
  61. type: object
  62. properties:
  63. data:
  64. type: object
  65. properties:
  66. token:
  67. type: string
  68. user:
  69. type: object
  70. properties:
  71. id: { type: string }
  72. nickName: { type: string }
  73. userName: { type: string }
  74. realName: { type: string }
  75. sn: { type: integer }
  76. avatar: { type: string, nullable: true }
  77. roles: { type: array, items: { type: string } }
  78. email: { type: string }
  79. 422:
  80. $ref: '../../main.yaml#/components/responses/ProblemValidation'
  81. 429:
  82. description: 尝试过于频繁
  83. content:
  84. application/problem+json:
  85. schema:
  86. $ref: '../../main.yaml#/components/schemas/ProblemDetails'