({
+ url: '/api/user/password/send-reset-email',
+ method: 'POST',
+ data: formModel,
+ showSuccessAlert: false,
+ showErrorAlert: false,
+ })
+ .subscribe({
+ next: (response) => {
+ const { error, message } = response.data; // the backend api can respond with 200 Ok but still have an error set
+
+ if (error) {
+ setError(error);
+ } else if (message) {
+ setEmailSent(true);
+ }
+
+ subscription.unsubscribe(); // unsubscribe as soon as a value is received
+ },
+ error: (err) => {
+ const dataError = toDataQueryError(err);
+ setError(dataError.message ?? 'Unknown error');
+ subscription.unsubscribe(); // unsubscribe as soon as an error is received
+ },
+ });
};
if (emailSent) {
@@ -40,29 +76,54 @@ export const ForgottenPassword: FC = () => {
);
}
- return (
-
+ return (
+ <>
+
+
+
+
+ Reason:
+ {error}
+
+
+
+ >
);
-};
+}
+
+function getStyles(theme: GrafanaTheme2) {
+ return css`
+ color: ${theme.colors.text.secondary};
+ font-size: ${theme.typography.size.sm};
+ font-weight: ${theme.typography.fontWeightRegular};
+ margin-top: ${theme.spacing(1)};
+ display: block;
+ `;
+}