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
4d181631
Commit
4d181631
authored
Sep 26, 2019
by
Tonk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update register and login
parent
e9ada991
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
17 deletions
+38
-17
screens/Public/AuthLoadingScreen.js
+10
-6
screens/Public/LoginScreen.js
+14
-1
screens/Public/RegisterScreen.js
+14
-10
No files found.
screens/Public/AuthLoadingScreen.js
View file @
4d181631
...
...
@@ -45,20 +45,24 @@ class AuthLoadingScreen extends Component {
// Preload data from an external API && Preload data using AsyncStorage
const
alreadyLaunched
=
await
AsyncStorage
.
getItem
(
'alreadyLaunched'
);
const
RememberedLogin
=
await
AsyncStorage
.
getItem
(
'RememberedLogin'
);
// console.log('alreadyLaunched', alreadyLaunched);
// console.log('RememberedLogin', RememberedLogin);
if
(
alreadyLaunched
===
'true'
)
{
if
(
RememberedLogin
===
'true'
)
{
app
.
auth
().
onAuthStateChanged
(
async
user
=>
{
if
(
user
)
{
console
.
log
(
user
);
await
this
.
props
.
getCurrentUser
(
user
);
await
this
.
getToken
();
this
.
props
.
navigation
.
navigate
(
RememberedLogin
===
'true'
?
'Main'
:
'Login'
);
// createMockData();
}
else
{
this
.
props
.
navigation
.
navigate
(
alreadyLaunched
===
'true'
?
'Login'
:
'Onboarding'
);
this
.
props
.
navigation
.
navigate
(
'Main'
);
}
});
}
else
{
app
.
auth
().
signOut
();
this
.
props
.
navigation
.
navigate
(
'Login'
);
}
}
else
{
this
.
props
.
navigation
.
navigate
(
'Onboarding'
);
}
}
catch
(
e
)
{
alert
(
e
);
}
...
...
screens/Public/LoginScreen.js
View file @
4d181631
...
...
@@ -5,8 +5,10 @@ import AsyncStorage from '@react-native-community/async-storage';
import
LoginForm
from
'../../components/Form/LoginForm'
;
import
{
KeyboardAvoidingView
,
View
}
from
'react-native'
;
import
app
from
'../../firebase'
;
import
{
getCurrentUser
}
from
'../../reduxStore/actions/cerrentUserAction'
;
import
{
connect
}
from
'react-redux'
;
export
default
class
LoginScreen
extends
Component
{
class
LoginScreen
extends
Component
{
static
navigationOptions
=
{
header
:
null
,
};
...
...
@@ -22,6 +24,8 @@ export default class LoginScreen extends Component {
try
{
const
userCredential
=
await
app
.
auth
().
signInWithEmailAndPassword
(
email
,
password
);
if
(
userCredential
)
{
const
user
=
app
.
auth
().
currentUser
;
await
this
.
props
.
getCurrentUser
(
user
);
await
AsyncStorage
.
setItem
(
'alreadyLaunched'
,
'true'
);
if
(
this
.
state
.
isCheck
===
true
)
{
await
AsyncStorage
.
setItem
(
'RememberedLogin'
,
'true'
);
...
...
@@ -74,3 +78,12 @@ export default class LoginScreen extends Component {
);
}
}
const mapDispatchToProps = {
getCurrentUser,
};
export default connect(
null,
mapDispatchToProps
)(LoginScreen);
screens/Public/RegisterScreen.js
View file @
4d181631
import
React
,
{
Component
}
from
'react'
;
import
{
Container
,
Text
,
CheckBox
,
Icon
}
from
'native-base'
;
import
{
Text
,
CheckBox
}
from
'native-base'
;
import
{
color
,
theme
}
from
'../../constants/Styles'
;
import
{
Platform
,
View
,
ScrollView
}
from
'react-native'
;
import
{
View
,
ScrollView
}
from
'react-native'
;
import
RegisterForm
from
'../../components/Form/RegisterForm'
;
import
{
HeaderButtons
,
Item
}
from
'react-navigation-header-buttons'
;
import
IoniconsHeaderButton
from
'../../components/IoniconsHeaderButton'
;
import
app
,
{
fireStore
,
baseURL
}
from
'../../firebase'
;
import
app
from
'../../firebase'
;
import
{
connect
}
from
'react-redux'
;
import
{
updateUser
}
from
'../../reduxStore/actions/cerrentUserAction'
;
import
{
getCurrentUser
,
updateUser
}
from
'../../reduxStore/actions/cerrentUserAction'
;
class
RegisterScreen
extends
Component
{
static
navigationOptions
=
({
navigation
})
=>
({
...
...
@@ -43,15 +43,20 @@ class RegisterScreen extends Component {
createAccount
=
async
values
=>
{
const
userData
=
{
firstName
:
values
.
firstName
,
lastName
:
values
.
lastName
,
phoneNumber
:
values
.
phoneno
};
try
{
const
reg
=
app
.
auth
().
createUserWithEmailAndPassword
(
values
.
email
,
values
.
password
);
const
reg
=
app
.
auth
()
.
createUserWithEmailAndPassword
(
values
.
email
,
values
.
password
)
.
then
(
async
value
=>
{
await
this
.
props
.
getCurrentUser
(
value
);
await
this
.
props
.
updateUser
(
userData
);
});
if
(
reg
)
{
this
.
props
.
updateUser
(
userData
);
// can't update data when create user
app
.
auth
().
signOut
();
this
.
props
.
navigation
.
navigate
(
'Success'
);
}
}
catch
(
error
)
{
console
.
log
(
error
);
alert
(
error
);
}
};
...
...
@@ -84,13 +89,12 @@ class RegisterScreen extends Component {
}
}
const
mapStateToProps
=
state
=>
({});
const
mapDispatchToProps
=
{
updateUser
,
getCurrentUser
,
};
export
default
connect
(
mapStateToProps
,
null
,
mapDispatchToProps
)(
RegisterScreen
);
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