@molecule/api-resource-user 1.11.0 → 1.11.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,16 +31,6 @@ router.post('/users/log-in', rateLimitAuth, async (req, res) => {
31
31
  })
32
32
 
33
33
  router.post('/users/logout', auth, createRequestHandler(handlers.logout()))
34
- router.post(
35
- '/users/forgot-password',
36
- rateLimitAuth,
37
- createRequestHandler(handlers.forgotPassword(resource)),
38
- )
39
- router.post(
40
- '/users/reset-password',
41
- rateLimitAuth,
42
- createRequestHandler(handlers.resetPassword(resource)),
43
- )
44
34
 
45
35
  // Keep current-user lookup before the parameterized route.
46
36
  router.get('/users/me', auth, createRequestHandler(handlers.readSelf(resource)))
@@ -52,16 +42,10 @@ router.patch(
52
42
  authSelf,
53
43
  createRequestHandler(handlers.updatePassword(resource)),
54
44
  )
55
- router.post(
56
- '/users/:id/verify-two-factor',
57
- authSelf,
58
- rateLimitTwoFactor,
59
- createRequestHandler(handlers.verifyTwoFactor(resource)),
60
- )
61
- router.patch('/users/:id/plan', authSelf, createRequestHandler(handlers.updatePlan(resource)))
62
45
 
63
- // Feature routers are mounted by the app when the corresponding provider is installed.
64
- /** OAuth initiation and credential exchange routes. */
46
+ /**
47
+ * OAuth initiation and credential exchange routes, mounted when the stack has an OAuth provider.
48
+ */
65
49
  export const oauthRouter = Router()
66
50
  oauthRouter.get(
67
51
  '/users/oauth/:provider',
@@ -74,8 +58,41 @@ oauthRouter.post(
74
58
  createRequestHandler(handlers.logInOAuth(resource)),
75
59
  )
76
60
 
77
- /** Authenticated billing routes and the provider webhook. */
61
+ /** Password reset by email, mounted with an email transport, which sends the reset link. */
62
+ export const emailsRouter = Router()
63
+ emailsRouter.post(
64
+ '/users/forgot-password',
65
+ rateLimitAuth,
66
+ createRequestHandler(handlers.forgotPassword(resource)),
67
+ )
68
+ emailsRouter.post(
69
+ '/users/reset-password',
70
+ rateLimitAuth,
71
+ createRequestHandler(handlers.resetPassword(resource)),
72
+ )
73
+
74
+ /**
75
+ * Two-factor set-up, enabling and disabling, mounted with a two-factor provider, which checks the
76
+ * codes.
77
+ */
78
+ export const twoFactorRouter = Router()
79
+ twoFactorRouter.post(
80
+ '/users/:id/verify-two-factor',
81
+ authSelf,
82
+ rateLimitTwoFactor,
83
+ createRequestHandler(handlers.verifyTwoFactor(resource)),
84
+ )
85
+
86
+ /**
87
+ * Plan changes, authenticated billing routes and the provider webhook, mounted with a payments
88
+ * provider.
89
+ */
78
90
  export const paymentsRouter = Router()
91
+ paymentsRouter.patch(
92
+ '/users/:id/plan',
93
+ authSelf,
94
+ createRequestHandler(handlers.updatePlan(resource)),
95
+ )
79
96
  const verifyPayment = createRequestHandler(handlers.verifyPayment(resource))
80
97
  paymentsRouter.get('/users/:id/verify-payment/:provider', authSelf, verifyPayment)
81
98
  paymentsRouter.post('/users/:id/verify-payment/:provider', authSelf, verifyPayment)