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. 10
      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 ActivateInstitutionCode from "../screens/ActivateInstitutionCode";
import ActivateInstitutionShowCode from "../screens/ActivateInstitutionShowCode";
import PasswordRecovery from "../screens/PasswordRecoveryScreen";
import PasswordRecoveryChangePswd from "../screens/PasswordRecoveryChangePswdScreen";
const Stack = createStackNavigator();
@ -78,15 +80,20 @@ const AccountNavigator = () => (
}}
/>
<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
name="EditUserData"
component={EditUserData}

7
src/app/navigation/AuthNavigator.js

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

10
src/app/screens/AccountScreen.js

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

10
src/app/screens/PasswordRecoveryScreen.js

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

Loading…
Cancel
Save