Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
safetcut-app
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
atichat
safetcut-app
Commits
589e7bf9
Commit
589e7bf9
authored
Sep 26, 2019
by
Tonk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update send reset password mail
parent
db654088
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
57 deletions
+61
-57
components/Form/ForgotPasswordForm.js
+42
-0
screens/Public/ForgotPasswordScreen.js
+10
-56
screens/Public/SendEmailScreen.js
+9
-1
No files found.
components/Form/ForgotPasswordForm.js
0 → 100644
View file @
589e7bf9
import
React
,
{
Component
}
from
'react'
;
import
{
Field
,
reduxForm
}
from
'redux-form'
;
import
Input
from
'./Input'
;
import
GradientBtn
from
'../GradientBtn'
;
import
{
theme
}
from
'../../constants/Styles'
;
// validation
const
required
=
value
=>
(
value
?
undefined
:
'This is a required field.'
);
const
email
=
value
=>
value
&&
!
/^
(([^
<>()
\[\]\\
.,;:
\s
@"
]
+
(\.[^
<>()
\[\]\\
.,;:
\s
@"
]
+
)
*
)
|
(
".+"
))
@
((\[[
0-9
]{1,3}\.[
0-9
]{1,3}\.[
0-9
]{1,3}\.[
0-9
]{1,3}
]
)
|
(([
a-zA-Z
\-
0-9
]
+
\.)
+
[
a-zA-Z
]{2,}))
$/i
.
test
(
value
)
?
'Invalid E-mail'
:
undefined
;
class
ForgotPassword
extends
Component
{
render
()
{
return
(
<>
<
Field
forwardRef
ref
=
{
c
=>
(
this
.
email
=
c
)}
refField
=
"email"
name
=
"email"
keyboardType
=
"email-address"
component
=
{
Input
}
validate
=
{[
required
,
email
]}
placeholder
=
"E-mail"
style
=
{
theme
.
containerWithVerticalMargin
}
/
>
<
GradientBtn
onPress
=
{
this
.
props
.
handleSubmit
}
title
=
{
'send'
}
/
>
<
/
>
);
}
}
const
ForgotPasswordForm
=
reduxForm
({
form
:
'forgotpassword'
,
})(
ForgotPassword
);
export
default
ForgotPasswordForm
;
screens/Public/ForgotPasswordScreen.js
View file @
589e7bf9
import
React
,
{
Component
}
from
'react'
;
import
{
Text
,
Icon
}
from
'native-base'
;
import
{
Text
}
from
'native-base'
;
import
{
View
}
from
'react-native'
;
import
{
theme
}
from
'../../constants/Styles'
;
import
{
Form
,
Field
}
from
'react-native-validate-form'
;
import
InputField
from
'../../components/InputField'
;
import
GradientBtn
from
'../../components/GradientBtn'
;
import
{
HeaderButtons
,
Item
}
from
'react-navigation-header-buttons'
;
import
IoniconsHeaderButton
from
'../../components/IoniconsHeaderButton'
;
// validations
const
required
=
value
=>
(
value
?
undefined
:
'This is a required field.'
);
const
email
=
value
=>
value
&&
!
/^
[
A-Z0-9._%+-
]
+@
[
A-Z0-9.-
]
+
\.[
A-Z
]{2,5}
$/i
.
test
(
value
)
?
'Please provide a valid email address.'
:
undefined
;
import
ForgotPasswordForm
from
'../../components/Form/ForgotPasswordForm'
;
import
app
from
'../../firebase'
;
export
default
class
ForgotPasswordScreen
extends
Component
{
static
navigationOptions
=
({
navigation
})
=>
({
title
:
undefined
,
// headerStyle: { borderBottomWidth: 0 },
headerLeft
:
(
<
HeaderButtons
HeaderButtonComponent
=
{
IoniconsHeaderButton
}
>
<
Item
title
=
"back"
iconName
=
"ios-arrow-back"
onPress
=
{()
=>
navigation
.
goBack
()}
dark
/>
...
...
@@ -25,28 +18,12 @@ export default class ForgotPasswordScreen extends Component {
headerRight
:
null
,
});
state
=
{
errors
:
[],
email
:
''
,
handleSubmit
=
async
values
=>
{
const
auth
=
app
.
auth
();
const
emailAddress
=
values
.
email
;
this
.
props
.
navigation
.
navigate
(
'SendEmail'
,
{
email
:
emailAddress
});
await
auth
.
sendPasswordResetEmail
(
emailAddress
);
};
submitForm
()
{
let
submitResults
=
this
.
registerForm
.
validate
();
let
errors
=
[];
submitResults
.
forEach
(
item
=>
{
errors
.
push
({
field
:
item
.
fieldName
,
error
:
item
.
error
});
});
this
.
setState
({
errors
:
errors
});
}
submitSuccess
()
{
console
.
log
(
'Submit Success!'
);
}
submitFailed
()
{
console
.
log
(
'Submit Failed!'
);
}
render
()
{
return
(
...
...
@@ -56,30 +33,7 @@ export default class ForgotPasswordScreen extends Component {
<
Text
style
=
{
theme
.
normalText
}
>
Please
enter
your
email
address
.
<
/Text
>
<
Text
style
=
{
theme
.
normalText
}
>
You
will
receive
a
link
to
create
a
new
password
via
email
.
<
/Text
>
<
/View
>
<
Form
ref
=
{
ref
=>
(
this
.
registerForm
=
ref
)}
validate
=
{
true
}
submit
=
{
this
.
submitSuccess
.
bind
(
this
)}
failed
=
{
this
.
submitFailed
.
bind
(
this
)}
errors
=
{
this
.
state
.
errors
}
style
=
{
theme
.
containerWithVerticalMargin
}
>
<
Field
required
component
=
{
InputField
}
validations
=
{[
required
,
email
]}
name
=
"email"
value
=
{
this
.
state
.
email
}
onChangeText
=
{
val
=>
this
.
setState
({
email
:
val
})}
placeholder
=
"Your E-mail"
/>
<
/Form
>
<
GradientBtn
onPress
=
{()
=>
{
this
.
props
.
navigation
.
navigate
(
'SendEmail'
);
}}
title
=
{
'send'
}
/
>
<
ForgotPasswordForm
onSubmit
=
{
this
.
handleSubmit
}
/
>
<
/View
>
);
}
...
...
screens/Public/SendEmailScreen.js
View file @
589e7bf9
...
...
@@ -3,11 +3,17 @@ import { Text, View, Button } from 'native-base';
import
{
Image
}
from
'react-native'
;
import
{
theme
}
from
'../../constants/Styles'
;
import
GradientBtn
from
'../../components/GradientBtn'
;
import
app
from
'../../firebase'
;
export
default
class
SendEmailScreen
extends
Component
{
static
navigationOptions
=
({
navigation
})
=>
({
header
:
null
,
});
resendMail
=
async
()
=>
{
const
email
=
this
.
props
.
navigation
.
getParam
(
'email'
);
const
auth
=
app
.
auth
();
await
auth
.
sendPasswordResetEmail
(
email
);
};
render
()
{
return
(
<
View
style
=
{[
theme
.
centerContainer
,
{
paddingHorizontal
:
50
}]}
>
...
...
@@ -35,7 +41,9 @@ export default class SendEmailScreen extends Component {
title
=
{
'done'
}
/
>
<
Button
full
transparent
style
=
{{
marginTop
:
10
}}
>
<
Text
style
=
{
theme
.
normalText
}
>
RESEND
<
/Text
>
<
Text
style
=
{
theme
.
normalText
}
onPress
=
{
this
.
resendMail
}
>
RESEND
<
/Text
>
<
/Button
>
<
/View
>
<
/View
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment