Skip to content

Commit

Permalink
password length limit added
Browse files Browse the repository at this point in the history
  • Loading branch information
starhubbot committed Apr 14, 2019
1 parent b3d8561 commit 18024c2
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 37 deletions.
39 changes: 21 additions & 18 deletions src/components/login/signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,27 @@ class Signin extends React.Component {
`Fill Out Empty Fields !`
);
} else {
const data = {
email: this.state.email.trim().toLowerCase(),
password: this.state.password
};
this.props
.signinUser(data,
res => {
if (this.state.autoSignIn) {
setTokens(res.user);
}
},
e =>
this.dropdown.alertWithType(
"error",
"Error !",
`${e}`
)
if (this.state.password.length < 6 || this.state.password.length > 20) {
this.dropdown.alertWithType(
"error",
"Error !",
`Password must contain between 6 and 20 characters.`
);
} else {
const data = {
email: this.state.email.trim().toLowerCase(),
password: this.state.password
};
this.props.signinUser(
data,
res => {
if (this.state.autoSignIn) {
setTokens(res.user);
}
},
e => this.dropdown.alertWithType("error", "Error !", `${e}`)
);
}
}
};

Expand Down Expand Up @@ -180,7 +183,7 @@ class Signin extends React.Component {
onPress={() =>
this.props.navigation.navigate("signUp", {
successHandler: () =>
this.dropdown.alertWithType(
this.dropdown.alertWithType(
"success",
"Welcome!",
"you have signed up successfully."
Expand Down
46 changes: 27 additions & 19 deletions src/components/login/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Signup extends React.Component {
signup = () => {
const { navigation } = this.props;
const successHandler = navigation.getParam("successHandler");

if (this.state.email.length == 0) {
this.dropdown.alertWithType("error", "Enter an Email", "Try Again !");
} else if (this.state.username.length == 0) {
Expand All @@ -74,22 +74,30 @@ class Signup extends React.Component {
"Try Again !"
);
} else {
const data = {
email: this.state.email.trim().toLowerCase(),
password: this.state.password,
username: this.state.username.trim().toLowerCase(),
avatar: `${uiAvatar}${this.state.username}`,
bio: ""
};
this.props
.registerUser(data)
.then(() => {
successHandler();
this.props.navigation.navigate("signIn");
})
.catch(e => {
this.dropdown.alertWithType("error", "Error !", e);
});
if (this.state.password.length < 6 || this.state.password.length > 20) {
this.dropdown.alertWithType(
"error",
"Error !",
`Password must contain between 6 and 20 characters.`
);
} else {
const data = {
email: this.state.email.trim().toLowerCase(),
password: this.state.password,
username: this.state.username.trim().toLowerCase(),
avatar: `${uiAvatar}${this.state.username}`,
bio: ""
};
this.props
.registerUser(data)
.then(() => {
successHandler();
this.props.navigation.navigate("signIn");
})
.catch(e => {
this.dropdown.alertWithType("error", "Error !", e);
});
}
}
}
};
Expand Down Expand Up @@ -213,7 +221,7 @@ const styles = StyleSheet.create({
backgroundColor: "white",
width: 300,
height: 50,
marginBottom: 10 ,
marginTop:20,
marginBottom: 10,
marginTop: 20
}
});

0 comments on commit 18024c2

Please sign in to comment.