Skip to content

Commit

Permalink
using Alert.alert instead of alert
Browse files Browse the repository at this point in the history
  • Loading branch information
Xuan Zhu authored and Xuan Zhu committed Dec 3, 2017
1 parent eaa3b8d commit 3894436
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions ForgotForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export class ForgotForm extends Component {
submit() {
firebase.auth().sendPasswordResetEmail(this.state.email)
.then(function() {
alert("Password Reset Email Sent!");
Alert.alert("Password Reset Email Sent!");
Actions.pop();
})
.catch(function(error) {
alert(error.message);
Alert.alert(error.message);
this.setState({
email: '',
});
Expand Down
14 changes: 7 additions & 7 deletions LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ import {
View,
TextInput,
TouchableOpacity,
StatusBar
StatusBar,
Alert
} from 'react-native';

import { Actions } from 'react-native-router-flux';
import * as firebase from 'firebase';


export class LoginForm extends Component {

constructor(props) {
super(props);
this.state = {
email: '',
password: '',
state: ''
};
this.onLoginPress=this.onLoginPress.bind(this);
}
Expand All @@ -32,7 +33,7 @@ export class LoginForm extends Component {

// email not empty
if(!uname.length) {
alert("Please enter email!");
Alert.alert("Please enter email!");
this.setState({
email: '',
password: '',
Expand All @@ -51,14 +52,13 @@ export class LoginForm extends Component {

// pw length, contains lower/upper case and special char
if(pw.length < 6 || pw.length > 12 || pw.toUpperCase() == pw || pw.toLowerCase() == pw || !speicalCharCheck(pw)) {
alert("Invalid Password!");
Alert.alert("Invalid Password!");
this.setState({
password: '',
});
return;
}


// authenticate email and password here
firebase.auth().signInWithEmailAndPassword(this.state.email, this.state.password)
.then(function() {
Expand All @@ -75,10 +75,10 @@ export class LoginForm extends Component {
var errorCode = error.code;
var errorMessage = error.message;
if (errorCode === 'auth/wrong-password') {
alert('Wrong password.');
Alert.alert('Wrong password.');
}
else {
alert(errorMessage);
Alert.alert(errorMessage);
}
this.setState({
password: '',
Expand Down
13 changes: 7 additions & 6 deletions SignupForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
View,
TextInput,
TouchableOpacity,
StatusBar
StatusBar,
Alert
} from 'react-native';

import { Actions } from 'react-native-router-flux';
Expand All @@ -33,7 +34,7 @@ export class SignupForm extends Component {

// email not empty
if(!uname.length) {
alert("Please enter email!");
Alert.alert("Please enter email!");
this.setState({
email: '',
password: '',
Expand All @@ -43,7 +44,7 @@ export class SignupForm extends Component {

// pw length
if(pw.length < 6 || pw.length > 12) {
alert("Invalid Password Length (6-12 characters)");
Alert.alert("Invalid Password", "Length should be 6-12 characters");
this.setState({
password: '',
});
Expand All @@ -52,7 +53,7 @@ export class SignupForm extends Component {

// has upper/lower chars
if(pw.toUpperCase() == pw || pw.toLowerCase() == pw) {
alert("Invalid Password (must contain Uppercase and Lowercase letters)");
Alert.alert("Invalid Password", "Password must contain at least one uppercase and lowercase letter.");
this.setState({
password: '',
});
Expand All @@ -72,7 +73,7 @@ export class SignupForm extends Component {
}

if(!speicalCharCheck(pw)) {
alert("Invalid Password (must contain one speical character)");
Alert.alert("Invalid Password", "Password must contain at least one speical character.");
this.setState({
password: '',
});
Expand All @@ -85,7 +86,7 @@ export class SignupForm extends Component {

firebase.auth().createUserWithEmailAndPassword(this.state.email, pw)
.then(function() {
alert("Sign up successful!");
Alert.alert("Sign up successful!");
// return to login page after sign up
Actions.pop();
})
Expand Down

0 comments on commit 3894436

Please sign in to comment.