Skip to content

Commit

Permalink
frontend/user: disable email-change if a user has chargers with older…
Browse files Browse the repository at this point in the history
… firmware.
  • Loading branch information
ffreddow committed Jan 16, 2025
1 parent 5c6db63 commit 5ead71a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion frontend/src/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const de ={
"update_user_failed": "Aktualisieren der Nutzerdaten mit dem Code {{status}} fehlgeschlagen: {{response}}",
"update_password_failed": "Aktualisieren des Passwortes mit dem Code {{status}} fehlgeschlagen: {{response}}",
"delete_user_failed": "Löschen des Nutzers mit dem Code {{status}} fehlgeschlagen: {{response}}",
"email_change_warning": "Ändern der E-Mail-Adresse zurzeit aus technischen Gründen nicht möglich"
"email_change_disabled": "Ändern der E-Mail-Adresse ist deaktiviert, da Du Geräte mit alter Firmware-Version konfiguriert hast. Bitte aktualisiere zuerst deine Geräte."
},
"recovery": {
"recovery": "Passwort zurücksetzen",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const en = {
"update_password_failed": "Updating the password failed with status code {{status}}: {{response}}",
"delete_user_failed": "Deleting user failed with status code {{status}}: {{response}}",
"account_actions": "Account Actions",
"email_change_warning": "Changing the email-address is currently not possible due to technical reasons"
"email_change_disabled": "Email changes are disabled because you have chargers with old firmware versions. Please update your chargers first."
},
"recovery": {
"recovery": "Password recovery",
Expand Down
17 changes: 10 additions & 7 deletions frontend/src/pages/user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import { Base64 } from "js-base64";
interface UserState {
id: string,
name: string,
email: string
email: string,
has_old_charger: boolean,
}

interface State {
Expand All @@ -56,6 +57,7 @@ class UserComponent extends Component<{}, State> {
id: "",
name: "",
email: "",
has_old_charger: false,
};

this.state = {
Expand All @@ -65,7 +67,6 @@ class UserComponent extends Component<{}, State> {

fetchClient.GET("/user/me", {credentials: "same-origin"}).then(({data, error, response}) => {
if (data) {
email = data.email;
this.setState({user: data});
} else if (error) {
showAlert(i18n.t("user.get_user_failed", {status: response.status, response: error}), "danger");
Expand Down Expand Up @@ -93,12 +94,14 @@ class UserComponent extends Component<{}, State> {
</Form.Group>
<Form.Group className="pb-3" controlId="userEmail">
<Form.Label className="text-muted">{t("email")}</Form.Label>
<Form.Control disabled type="email" value={this.state.user.email} onChange={(e) => {
<Form.Control type="email" value={this.state.user.email} onChange={(e) => {
this.setState({user: {...this.state.user, email: (e.target as HTMLInputElement).value}, isDirty: true});
}} />
<Form.Text className="text-danger">
{t("email_change_warning")}
</Form.Text>
}} disabled={this.state.user.has_old_charger} />
{this.state.user.has_old_charger &&
<Form.Text className="text-danger">
{t("email_change_disabled")}
</Form.Text>
}
</Form.Group>
<Form.Group className="pb-3" controlId="userName">
<Form.Label className="text-muted">{t("name")}</Form.Label>
Expand Down

0 comments on commit 5ead71a

Please sign in to comment.