Skip to content

Commit cbe6dec

Browse files
author
Ervin
committed
Merge branch 'master' of github.com:Tourniercy/RunningApp
2 parents 15acbc3 + d5c1152 commit cbe6dec

File tree

8 files changed

+191
-363
lines changed

8 files changed

+191
-363
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ App/node_modules
33
.idea
44
App/.expo
55
package-lock.json
6-
.DS_Storecd
6+
.DS_Storecd
7+
Web/.php-version

App/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
API_URL=http://122e27b1.ngrok.io
1+
API_URL=http://e9c1e508.ngrok.io

App/auth/Auth.js

Lines changed: 51 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,65 @@
1-
import { AsyncStorage } from "react-native";
1+
import {AsyncStorage} from "react-native";
22
import config from '../config/config';
33

44
let USER_TOKEN = "";
55
let USER_REFRESH_TOKEN = "";
66
let USER_ID = "";
77

88
export async function getToken(values) {
9+
console.log(config);
10+
return await
911

10-
let token = await
11-
12-
fetch(``+config.API_URL+`/api/login_check`, {
13-
14-
method: 'POST',
15-
headers: {
16-
Accept: 'application/json',
17-
'Content-Type': 'application/json',
18-
},
19-
body: JSON.stringify({
20-
"username": values.email,
21-
"password": values.password,
22-
})
23-
})
24-
.then(async resp => {
25-
26-
return resp.json()
27-
})
28-
.then(async responseData => {
29-
30-
if (responseData.token) {
31-
let id = await fetch(``+config.API_URL+`/users/check/` + values.email, {
12+
fetch(`` + config.API_URL + `/api/login_check`, {
3213

3314
method: 'POST',
3415
headers: {
35-
Accept: 'application/json',
36-
'Content-Type': 'application/json',
37-
}
38-
})
39-
.then(async resp => {
40-
41-
return resp.json()
42-
})
43-
.then(async responseData => {
44-
return responseData.id
45-
})
46-
47-
USER_ID = await id
48-
USER_TOKEN = await responseData.token
49-
USER_REFRESH_TOKEN = await responseData.refresh_token
50-
51-
await onSignIn()
52-
return 200
53-
}
54-
else if (responseData.code === 401) {
55-
return 401
56-
}
57-
else if (responseData.code === 500) {
58-
return 500
59-
}
60-
61-
})
62-
.catch(err => {
63-
console.log(err)
64-
})
65-
66-
return token
16+
Accept: 'application/json',
17+
'Content-Type': 'application/json',
18+
},
19+
body: JSON.stringify({
20+
"username": values.email,
21+
"password": values.password,
22+
})
23+
})
24+
.then(async resp => {
25+
26+
return resp.json()
27+
})
28+
.then(async responseData => {
29+
30+
if (responseData.token) {
31+
let id = await fetch(`` + config.API_URL + `/users/check/` + values.email, {
32+
33+
method: 'POST',
34+
headers: {
35+
Accept: 'application/json',
36+
'Content-Type': 'application/json',
37+
}
38+
})
39+
.then(async resp => {
40+
41+
return resp.json()
42+
})
43+
.then(async responseData => {
44+
return responseData.id
45+
})
46+
47+
USER_ID = await id
48+
USER_TOKEN = await responseData.token
49+
USER_REFRESH_TOKEN = await responseData.refresh_token
50+
51+
await onSignIn()
52+
return 200
53+
} else if (responseData.code === 401) {
54+
return 401
55+
} else if (responseData.code === 500) {
56+
return 500
57+
}
58+
59+
})
60+
.catch(err => {
61+
console.log(err)
62+
})
6763
}
6864

6965
export const onSignIn = async () => {

App/config/config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { API_URL } from 'react-native-dotenv';
22

3+
4+
5+
6+
7+
8+
39
export default {
410
API_URL,
511
};

0 commit comments

Comments
 (0)