Browse Source

Enabling already logged-in user to change password.

master
GabrielTrettel 3 years ago
parent
commit
8c651def82
  1. 23
      src/app/navigation/AccountNavigator.js
  2. 7
      src/app/navigation/AuthNavigator.js
  3. 12
      src/app/screens/AccountScreen.js
  4. 10
      src/app/screens/PasswordRecoveryScreen.js

23
src/app/navigation/AccountNavigator.js

@ -9,6 +9,8 @@ import UpdatePassword from "../screens/UpdatePassword";
import EditUserData from "../screens/EditUserData"; import EditUserData from "../screens/EditUserData";
import ActivateInstitutionCode from "../screens/ActivateInstitutionCode"; import ActivateInstitutionCode from "../screens/ActivateInstitutionCode";
import ActivateInstitutionShowCode from "../screens/ActivateInstitutionShowCode"; import ActivateInstitutionShowCode from "../screens/ActivateInstitutionShowCode";
import PasswordRecovery from "../screens/PasswordRecoveryScreen";
import PasswordRecoveryChangePswd from "../screens/PasswordRecoveryChangePswdScreen";
const Stack = createStackNavigator(); const Stack = createStackNavigator();
@ -78,15 +80,20 @@ const AccountNavigator = () => (
}} }}
/> />
<Stack.Screen <Stack.Screen
name="UpdatePassword"
component={UpdatePassword}
options={{
title: "",
headerStyle: {
backgroundColor: "white",
},
}}
name="PasswordRecovery"
component={PasswordRecovery}
initialParams={{ user : {} }}
options={{ headerTitle: "" }}
/> />
<Stack.Screen
name="PasswordRecoveryChangePswd"
component={PasswordRecoveryChangePswd}
initialParams={{ authToken : "" }}
options={{ headerTitle: "" }}
/>
<Stack.Screen <Stack.Screen
name="EditUserData" name="EditUserData"
component={EditUserData} component={EditUserData}

7
src/app/navigation/AuthNavigator.js

@ -19,18 +19,19 @@ const AuthNavigator = () => (
<Stack.Screen <Stack.Screen
name="Register" name="Register"
component={RegisterScreen} component={RegisterScreen}
options={{ headerTitle: "" }} //headerStyle: {backgroundColor: colors.primary} }}
options={{ headerTitle: "" }}
/> />
<Stack.Screen <Stack.Screen
name="UserAgreement" name="UserAgreement"
component={UserAgreement} component={UserAgreement}
options={{ headerTitle: "" }} //headerStyle: {backgroundColor: colors.primary} }}
options={{ headerTitle: "" }}
/> />
<Stack.Screen <Stack.Screen
name="PasswordRecovery" name="PasswordRecovery"
component={PasswordRecovery} component={PasswordRecovery}
options={{ headerTitle: "" }} //headerStyle: {backgroundColor: colors.primary} }}
initialParams={{ user : {} }}
options={{ headerTitle: "" }}
/> />
<Stack.Screen <Stack.Screen

12
src/app/screens/AccountScreen.js

@ -122,7 +122,16 @@ function AccountScreen(props) {
} }
const profileItems = [
const profileItems = [
{
icon: "lock",
show: true,
IconProvider: MaterialCommunityIcons,
title: "alterar senha",
onPress: () => {
props.navigation.navigate("PasswordRecovery", {user: user});
},
},
{ {
icon: "account", icon: "account",
show: user.pluviometer != undefined, show: user.pluviometer != undefined,
@ -160,6 +169,7 @@ function AccountScreen(props) {
setShowLog(true); setShowLog(true);
}, },
}, },
{ {
icon: "login", icon: "login",
show: !isRegistered, show: !isRegistered,

10
src/app/screens/PasswordRecoveryScreen.js

@ -65,7 +65,10 @@ const validationSchema = Yup.object().shape({
.max(255), .max(255),
}); });
export default function PasswordRecovery({ navigation }) {
export default function PasswordRecovery({ navigation, route }) {
const user = route.params.user;
console.log(user)
const [showLoading, setShowLoading] = useState(false); const [showLoading, setShowLoading] = useState(false);
const [confirmatioModalData, setConfirmatioModalData] = useState({ const [confirmatioModalData, setConfirmatioModalData] = useState({
show: false, show: false,
@ -142,7 +145,7 @@ export default function PasswordRecovery({ navigation }) {
<Form <Form
validationSchema={validationSchema} validationSchema={validationSchema}
initialValues={{ initialValues={{
number: "",
number: user.username || "",
answer: "", answer: "",
secQuestion: "", secQuestion: "",
}} }}
@ -163,7 +166,8 @@ export default function PasswordRecovery({ navigation }) {
<PhoneNumberFormField <PhoneNumberFormField
name="number" name="number"
maxLength={11} maxLength={11}
placeholder="(DDD) XXXXX-XXXX"
placeholder={"(DDD) XXXXX-XXXX"}
editable={user.username == null}
/> />
</View> </View>

Loading…
Cancel
Save