({
- 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
- },
- });
+ const sendEmail = async (formModel: EmailDTO) => {
+ const res = await getBackendSrv().post('/api/user/password/send-reset-email', formModel);
+ if (res) {
+ setEmailSent(true);
+ }
};
if (emailSent) {
@@ -76,54 +40,29 @@ export function ForgottenPassword(): JSX.Element {
);
}
-
return (
- <>
-
-
-
-
- Reason:
- {error}
-
-
-
- >
+ Did you forget your username or email? Contact your Grafana administrator.
+ >
+ )}
+
);
-}
-
-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;
- `;
-}
+};