IO-1274 Change Password on profilel
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<babeledit_project version="1.2" be_version="2.7.1">
|
<babeledit_project be_version="2.7.1" version="1.2">
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
BabelEdit project file
|
BabelEdit project file
|
||||||
@@ -13570,6 +13570,27 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</translations>
|
</translations>
|
||||||
</concept_node>
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>newpassword</name>
|
||||||
|
<definition_loaded>false</definition_loaded>
|
||||||
|
<description></description>
|
||||||
|
<comment></comment>
|
||||||
|
<default_text></default_text>
|
||||||
|
<translations>
|
||||||
|
<translation>
|
||||||
|
<language>en-US</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>es-MX</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>fr-CA</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
</translations>
|
||||||
|
</concept_node>
|
||||||
<concept_node>
|
<concept_node>
|
||||||
<name>no</name>
|
<name>no</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
@@ -37182,6 +37203,27 @@
|
|||||||
<folder_node>
|
<folder_node>
|
||||||
<name>actions</name>
|
<name>actions</name>
|
||||||
<children>
|
<children>
|
||||||
|
<concept_node>
|
||||||
|
<name>changepassword</name>
|
||||||
|
<definition_loaded>false</definition_loaded>
|
||||||
|
<description></description>
|
||||||
|
<comment></comment>
|
||||||
|
<default_text></default_text>
|
||||||
|
<translations>
|
||||||
|
<translation>
|
||||||
|
<language>en-US</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>es-MX</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>fr-CA</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
</translations>
|
||||||
|
</concept_node>
|
||||||
<concept_node>
|
<concept_node>
|
||||||
<name>signout</name>
|
<name>signout</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
@@ -37367,6 +37409,32 @@
|
|||||||
</concept_node>
|
</concept_node>
|
||||||
</children>
|
</children>
|
||||||
</folder_node>
|
</folder_node>
|
||||||
|
<folder_node>
|
||||||
|
<name>successess</name>
|
||||||
|
<children>
|
||||||
|
<concept_node>
|
||||||
|
<name>passwordchanged</name>
|
||||||
|
<definition_loaded>false</definition_loaded>
|
||||||
|
<description></description>
|
||||||
|
<comment></comment>
|
||||||
|
<default_text></default_text>
|
||||||
|
<translations>
|
||||||
|
<translation>
|
||||||
|
<language>en-US</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>es-MX</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>fr-CA</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
</translations>
|
||||||
|
</concept_node>
|
||||||
|
</children>
|
||||||
|
</folder_node>
|
||||||
</children>
|
</children>
|
||||||
</folder_node>
|
</folder_node>
|
||||||
<folder_node>
|
<folder_node>
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
import { Button, Form, Input } from "antd";
|
import { Button, Form, Input, notification } from "antd";
|
||||||
|
import { LockOutlined } from "@ant-design/icons";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { updateUserDetails } from "../../redux/user/user.actions";
|
import { updateUserDetails } from "../../redux/user/user.actions";
|
||||||
import { selectCurrentUser } from "../../redux/user/user.selectors";
|
import { selectCurrentUser } from "../../redux/user/user.selectors";
|
||||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
import {
|
||||||
|
logImEXEvent,
|
||||||
|
updateCurrentPassword,
|
||||||
|
} from "../../firebase/firebase.utils";
|
||||||
|
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
currentUser: selectCurrentUser,
|
currentUser: selectCurrentUser,
|
||||||
@@ -28,33 +33,96 @@ export default connect(
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleChangePassword = async ({ password }) => {
|
||||||
|
logImEXEvent("password_update");
|
||||||
|
try {
|
||||||
|
await updateCurrentPassword(password);
|
||||||
|
notification.success({
|
||||||
|
message: t("user.successess.passwordchanged"),
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
notification.error({
|
||||||
|
message: error.message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Form
|
<Form
|
||||||
onFinish={handleFinish}
|
onFinish={handleFinish}
|
||||||
autoComplete={"no"}
|
autoComplete={"no"}
|
||||||
initialValues={currentUser}
|
initialValues={currentUser}
|
||||||
|
layout="vertical"
|
||||||
>
|
>
|
||||||
<Form.Item
|
<LayoutFormRow>
|
||||||
label={t("user.fields.displayname")}
|
<Form.Item
|
||||||
rules={[
|
label={t("user.fields.displayname")}
|
||||||
{
|
rules={[
|
||||||
required: true,
|
{
|
||||||
//message: t("general.validation.required"),
|
required: true,
|
||||||
},
|
//message: t("general.validation.required"),
|
||||||
]}
|
},
|
||||||
name="displayName"
|
]}
|
||||||
>
|
name="displayName"
|
||||||
<Input />
|
>
|
||||||
</Form.Item>
|
<Input />
|
||||||
<Form.Item label={t("user.fields.photourl")} name="photoURL">
|
</Form.Item>
|
||||||
<Input />
|
<Form.Item label={t("user.fields.photourl")} name="photoURL">
|
||||||
</Form.Item>
|
<Input />
|
||||||
|
</Form.Item>
|
||||||
|
</LayoutFormRow>
|
||||||
|
|
||||||
<Button type="primary" key="submit" htmlType="submit">
|
<Button type="primary" key="submit" htmlType="submit">
|
||||||
{t("user.actions.updateprofile")}
|
{t("user.actions.updateprofile")}
|
||||||
</Button>
|
</Button>
|
||||||
</Form>
|
</Form>
|
||||||
|
<Form
|
||||||
|
onFinish={handleChangePassword}
|
||||||
|
autoComplete={"no"}
|
||||||
|
initialValues={currentUser}
|
||||||
|
layout="vertical"
|
||||||
|
>
|
||||||
|
<LayoutFormRow>
|
||||||
|
<Form.Item label={t("general.labels.newpassword")} name="password">
|
||||||
|
<Input
|
||||||
|
prefix={<LockOutlined />}
|
||||||
|
type="password"
|
||||||
|
placeholder={t("general.labels.password")}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
label={t("general.labels.confirmpassword")}
|
||||||
|
name="password-confirm"
|
||||||
|
dependencies={["password"]}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
},
|
||||||
|
({ getFieldValue }) => ({
|
||||||
|
validator(rule, value) {
|
||||||
|
if (!value || getFieldValue("password") === value) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
return Promise.reject(
|
||||||
|
t("general.labels.passwordsdonotmatch")
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
prefix={<LockOutlined />}
|
||||||
|
type="password"
|
||||||
|
placeholder={t("general.labels.password")}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
</LayoutFormRow>
|
||||||
|
<Button type="primary" key="submit" htmlType="submit">
|
||||||
|
{t("user.actions.changepassword")}
|
||||||
|
</Button>
|
||||||
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -35,6 +35,24 @@ export const updateCurrentUser = (userDetails) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const updateCurrentPassword = async (password) => {
|
||||||
|
const currentUser = await getCurrentUser();
|
||||||
|
|
||||||
|
return currentUser.updatePassword(password);
|
||||||
|
|
||||||
|
// return new Promise((resolve, reject) => {
|
||||||
|
// const unsubscribe = auth.onAuthStateChanged(
|
||||||
|
// (userAuth) => {
|
||||||
|
// userAuth.updatePassword(password).then((r) => {
|
||||||
|
// unsubscribe();
|
||||||
|
// resolve(userAuth);
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
// (error) => reject(error)
|
||||||
|
// );
|
||||||
|
// });
|
||||||
|
};
|
||||||
|
|
||||||
let messaging;
|
let messaging;
|
||||||
try {
|
try {
|
||||||
messaging = firebase.messaging();
|
messaging = firebase.messaging();
|
||||||
|
|||||||
@@ -100,8 +100,12 @@ export function* onUpdateUserDetails() {
|
|||||||
}
|
}
|
||||||
export function* updateUserDetails(userDetails) {
|
export function* updateUserDetails(userDetails) {
|
||||||
try {
|
try {
|
||||||
yield updateCurrentUser(userDetails.payload);
|
const updatedDetails = yield updateCurrentUser(userDetails.payload);
|
||||||
yield put(updateUserDetailsSuccess(userDetails.payload));
|
console.log(
|
||||||
|
"🚀 ~ file: user.sagas.js ~ line 104 ~ updatedDetails",
|
||||||
|
updatedDetails
|
||||||
|
);
|
||||||
|
yield put(updateUserDetailsSuccess(updatedDetails));
|
||||||
notification.open({
|
notification.open({
|
||||||
type: "success",
|
type: "success",
|
||||||
message: i18next.t("profile.successes.updated"),
|
message: i18next.t("profile.successes.updated"),
|
||||||
|
|||||||
@@ -862,6 +862,7 @@
|
|||||||
"message": "Message",
|
"message": "Message",
|
||||||
"monday": "Monday",
|
"monday": "Monday",
|
||||||
"na": "N/A",
|
"na": "N/A",
|
||||||
|
"newpassword": "New Password",
|
||||||
"no": "No",
|
"no": "No",
|
||||||
"nointernet": "It looks like you're not connected to the internet.",
|
"nointernet": "It looks like you're not connected to the internet.",
|
||||||
"nointernet_sub": "Please check your connection and try again. ",
|
"nointernet_sub": "Please check your connection and try again. ",
|
||||||
@@ -2226,6 +2227,7 @@
|
|||||||
},
|
},
|
||||||
"user": {
|
"user": {
|
||||||
"actions": {
|
"actions": {
|
||||||
|
"changepassword": "Change Password",
|
||||||
"signout": "Sign Out",
|
"signout": "Sign Out",
|
||||||
"updateprofile": "Update Profile"
|
"updateprofile": "Update Profile"
|
||||||
},
|
},
|
||||||
@@ -2240,6 +2242,9 @@
|
|||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"actions": "Actions"
|
"actions": "Actions"
|
||||||
|
},
|
||||||
|
"successess": {
|
||||||
|
"passwordchanged": "Password changed successfully. "
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"vehicles": {
|
"vehicles": {
|
||||||
|
|||||||
@@ -862,6 +862,7 @@
|
|||||||
"message": "",
|
"message": "",
|
||||||
"monday": "",
|
"monday": "",
|
||||||
"na": "N / A",
|
"na": "N / A",
|
||||||
|
"newpassword": "",
|
||||||
"no": "",
|
"no": "",
|
||||||
"nointernet": "",
|
"nointernet": "",
|
||||||
"nointernet_sub": "",
|
"nointernet_sub": "",
|
||||||
@@ -2226,6 +2227,7 @@
|
|||||||
},
|
},
|
||||||
"user": {
|
"user": {
|
||||||
"actions": {
|
"actions": {
|
||||||
|
"changepassword": "",
|
||||||
"signout": "desconectar",
|
"signout": "desconectar",
|
||||||
"updateprofile": "Actualización del perfil"
|
"updateprofile": "Actualización del perfil"
|
||||||
},
|
},
|
||||||
@@ -2240,6 +2242,9 @@
|
|||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"actions": ""
|
"actions": ""
|
||||||
|
},
|
||||||
|
"successess": {
|
||||||
|
"passwordchanged": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"vehicles": {
|
"vehicles": {
|
||||||
|
|||||||
@@ -862,6 +862,7 @@
|
|||||||
"message": "",
|
"message": "",
|
||||||
"monday": "",
|
"monday": "",
|
||||||
"na": "N / A",
|
"na": "N / A",
|
||||||
|
"newpassword": "",
|
||||||
"no": "",
|
"no": "",
|
||||||
"nointernet": "",
|
"nointernet": "",
|
||||||
"nointernet_sub": "",
|
"nointernet_sub": "",
|
||||||
@@ -2226,6 +2227,7 @@
|
|||||||
},
|
},
|
||||||
"user": {
|
"user": {
|
||||||
"actions": {
|
"actions": {
|
||||||
|
"changepassword": "",
|
||||||
"signout": "Déconnexion",
|
"signout": "Déconnexion",
|
||||||
"updateprofile": "Mettre à jour le profil"
|
"updateprofile": "Mettre à jour le profil"
|
||||||
},
|
},
|
||||||
@@ -2240,6 +2242,9 @@
|
|||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"actions": ""
|
"actions": ""
|
||||||
|
},
|
||||||
|
"successess": {
|
||||||
|
"passwordchanged": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"vehicles": {
|
"vehicles": {
|
||||||
|
|||||||
Reference in New Issue
Block a user