Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
ThaliApp
Commits
da1a78c5
Commit
da1a78c5
authored
May 16, 2017
by
Wietse Kuipers
Browse files
Logging in works again
parent
b1a61a55
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/actions/login.js
View file @
da1a78c5
...
...
@@ -33,7 +33,7 @@ export function loginFailure() {
};
}
async
function
getUserInfo
(
token
)
{
function
getUserInfo
(
token
)
{
const
data
=
{
method
:
'
GET
'
,
headers
:
{
...
...
@@ -43,16 +43,12 @@ async function getUserInfo(token) {
},
};
fetch
(
'
http://localhost:8000/api/members/info/
'
,
data
)
return
fetch
(
'
http://localhost:8000/api/members/info/
'
,
data
)
.
then
(
(
response
)
=>
{
console
.
log
(
response
);
return
response
.
json
();
})
response
=>
response
.
json
())
.
then
(
(
responseJson
)
=>
{
const
avatar
=
responseJson
.
photo
===
null
?
defaultAvatar
:
responseJson
.
photo
;
return
{
photo
:
avatar
,
displayName
:
responseJson
.
display_name
,
...
...
@@ -77,8 +73,8 @@ export function login(user, pass) {
'
Content-Type
'
:
'
application/json
'
,
},
body
:
JSON
.
stringify
({
user
,
pass
,
username
:
user
,
password
:
pass
,
}),
};
return
fetch
(
'
http://localhost:8000/api/token-auth/
'
,
data
)
...
...
@@ -88,22 +84,19 @@ export function login(user, pass) {
(
responseJson
)
=>
{
if
(
responseJson
.
token
)
{
const
token
=
responseJson
.
token
;
const
username
=
responseJson
.
username
;
getUserInfo
(
token
)
return
getUserInfo
(
token
)
.
then
(
(
userInfo
)
=>
{
console
.
log
(
userInfo
);
AsyncStorage
.
multiSet
([
[
USERNAMEKEY
,
username
],
[
TOKENKEY
,
token
],
[
DISPLAYNAMEKEY
,
userInfo
.
displayName
],
[
PHOTOKEY
,
userInfo
.
photo
],
]);
dispatch
(
loginSuccess
(
username
,
token
,
userInfo
.
displayName
,
userInfo
.
photo
));
},
);
userInfo
=>
AsyncStorage
.
multiSet
([
[
USERNAMEKEY
,
user
],
[
TOKENKEY
,
token
],
[
DISPLAYNAMEKEY
,
userInfo
.
displayName
],
[
PHOTOKEY
,
userInfo
.
photo
],
])
.
then
(()
=>
dispatch
(
loginSuccess
(
user
,
token
,
userInfo
.
displayName
,
userInfo
.
photo
,
)),
));
}
return
dispatch
(
loginFailure
());
})
...
...
app/components/navigator.js
View file @
da1a78c5
...
...
@@ -62,7 +62,7 @@ const ReduxNavigator = (props) => {
tapToClose
>
<
View
style
=
{
styles
.
statusBar
}
>
<
StatusBar
backgroundColor
=
{
colors
.
darkMagenta
}
barStyle
=
'
light-content
'
/>
<
StatusBar
backgroundColor
=
{
colors
.
darkMagenta
}
barStyle
=
"
light-content
"
/>
<
/View
>
<
View
style
=
{
styles
.
appBar
}
>
<
TouchableOpacity
...
...
@@ -83,7 +83,7 @@ const ReduxNavigator = (props) => {
return
(
<
View
>
<
View
style
=
{
styles
.
statusBar
}
>
<
StatusBar
backgroundColor
=
{
colors
.
darkMagenta
}
barStyle
=
'
light-content
'
/>
<
StatusBar
backgroundColor
=
{
colors
.
darkMagenta
}
barStyle
=
"
light-content
"
/>
<
/View
>
<
Login
/>
<
/View>
)
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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