MCPcopy
hub / github.com/FlowiseAI/Flowise / ForgotPasswordPage

Function ForgotPasswordPage

packages/ui/src/views/auth/forgotPassword.jsx:29–158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27// ==============================|| ForgotPasswordPage ||============================== //
28
29const ForgotPasswordPage = () => {
30 const theme = useTheme()
31 useNotifier()
32
33 const usernameInput = {
34 label: 'Username',
35 name: 'username',
36 type: 'email',
37 placeholder: 'user@company.com'
38 }
39 const [usernameVal, setUsernameVal] = useState('')
40 const { isEnterpriseLicensed } = useConfig()
41
42 const [isLoading, setLoading] = useState(false)
43 const [responseMsg, setResponseMsg] = useState(undefined)
44
45 const { authRateLimitError, setAuthRateLimitError } = useError()
46
47 const forgotPasswordApi = useApi(accountApi.forgotPassword)
48
49 const sendResetRequest = async (event) => {
50 event.preventDefault()
51 setAuthRateLimitError(null)
52 const body = {
53 user: {
54 email: usernameVal
55 }
56 }
57 setLoading(true)
58 await forgotPasswordApi.request(body)
59 }
60
61 useEffect(() => {
62 setAuthRateLimitError(null)
63 // eslint-disable-next-line react-hooks/exhaustive-deps
64 }, [setAuthRateLimitError])
65
66 useEffect(() => {
67 if (forgotPasswordApi.error) {
68 const errMessage =
69 typeof forgotPasswordApi.error.response.data === 'object'
70 ? forgotPasswordApi.error.response.data.message
71 : forgotPasswordApi.error.response.data
72 setResponseMsg({
73 type: 'error',
74 msg: errMessage ?? 'Failed to send instructions, please contact your administrator.'
75 })
76 setLoading(false)
77 }
78 // eslint-disable-next-line react-hooks/exhaustive-deps
79 }, [forgotPasswordApi.error])
80
81 useEffect(() => {
82 if (forgotPasswordApi.data) {
83 setResponseMsg({
84 type: 'success',
85 msg: 'Password reset instructions sent to the email.'
86 })

Callers

nothing calls this directly

Calls 3

useConfigFunction · 0.90
useErrorFunction · 0.90
useNotifierFunction · 0.85

Tested by

no test coverage detected