Fix password reset regression

pull/692/head
Rick Carlino 2018-03-02 08:52:06 -06:00
parent 6e2b64b39c
commit 393337e1c9
2 changed files with 4 additions and 10 deletions

View File

@ -63,7 +63,7 @@ FarmBot::Application.routes.draw do
get "/tos_update" => "dashboard#tos_update", as: :tos_update
post "/csp_reports" => "dashboard#csp_reports", as: :csp_report
get "/password_reset/:token" => "dashboard#password_reset", as: :password_reset
get "/password_reset/*token" => "dashboard#password_reset", as: :password_reset
get "/verify/:token" => "dashboard#verify", as: :verify_user
match "/app/*path", to: "dashboard#main_app", via: :all, constraints: { format: "html" }

View File

@ -10,7 +10,7 @@ import {
import { SpecialStatus } from "../../resources/tagged_resources";
import Axios from "axios";
import { API } from "../../api/index";
import { prettyPrintApiErrors } from "../../util";
import { prettyPrintApiErrors, equals } from "../../util";
import { success, error } from "farmbot-toastr/dist";
interface PasswordForm {
@ -37,8 +37,8 @@ export class ChangePassword extends React.Component<{}, ChangePWState> {
/** Set the `status` flag to `undefined`, but only if the form is empty.
* Useful when the user manually clears the form. */
maybeClearForm = () => wowFixMe(EMPTY_FORM, this.state.form) ?
this.clearForm() : false;
maybeClearForm =
() => equals(EMPTY_FORM, this.state.form) ? this.clearForm() : false;
clearForm = () => this.setState({ status: SpecialStatus.SAVED, form: EMPTY_FORM });
@ -103,9 +103,3 @@ export class ChangePassword extends React.Component<{}, ChangePWState> {
</Widget>;
}
}
// TODO: Why does Object.is() not work when comparing EMPTY_FORM to
// this.state.form? Using this in the meantime. PRs and feedback welcome.
function wowFixMe<T>(l: T, r: T): boolean {
return (JSON.stringify(l) === JSON.stringify(r));
}