Commit e920b62a authored by Lihinikaduwa D.N.R.  's avatar Lihinikaduwa D.N.R.

Authorized the user

parent fbbe91b9
...@@ -179,4 +179,4 @@ def reading(): ...@@ -179,4 +179,4 @@ def reading():
if __name__ == "__main__": if __name__ == "__main__":
app.run(host='192.168.8.101') app.run(host='192.168.1.100')
...@@ -12,7 +12,7 @@ def create_con(): ...@@ -12,7 +12,7 @@ def create_con():
database="helply", database="helply",
host="127.0.0.1", host="127.0.0.1",
user="root", user="root",
password="rp19970520" password="12345678"
) )
return db return db
......
import {useNavigation} from '@react-navigation/native';
import AsyncStorage from '@react-native-async-storage/async-storage';
export function Authorize() {
const navigation = useNavigation();
AsyncStorage.getItem('userToken')
.then(value => {
console.log(value);
if (value) {
return value;
} else {
alert('Please Login.......');
navigation.navigate('Login');
}
})
.catch(error => {
console.log(error);
});
}
...@@ -97,8 +97,8 @@ const Login = () => { ...@@ -97,8 +97,8 @@ const Login = () => {
return updateError('Please register our system', setError); return updateError('Please register our system', setError);
} }
if (response.data.status == 200) { if (response.data.status == 200) {
const sessionToken = res.data.token; const userToken = res.data.token;
AsyncStorage.setItem('token', token); AsyncStorage.setItem('userToken', userToken);
return navigation.navigate('Start'); return navigation.navigate('Start');
} }
}) })
......
...@@ -18,15 +18,18 @@ import {DummyReadResult} from '../../../assets/read/data/ReadData'; ...@@ -18,15 +18,18 @@ import {DummyReadResult} from '../../../assets/read/data/ReadData';
import AudioRecord from 'react-native-audio-record'; import AudioRecord from 'react-native-audio-record';
import Client from '../../client/Client'; import Client from '../../client/Client';
import AsyncStorage from '@react-native-async-storage/async-storage'; import AsyncStorage from '@react-native-async-storage/async-storage';
import {Authorize} from '../../auth/AuthenticateUser';
export default function ReadActivityBird() { export default function ReadActivityBird() {
const [pitch, setPitch] = useState(''); const userToken = Authorize();
const [error, setError] = useState(''); const [error, setError] = useState('');
const [readingData, setReadingData] = useState({activity: ''}); const [readingData, setReadingData] = useState({activity: ''});
const [started, setStarted] = useState(''); const readToken = AsyncStorage.getItem('readingSession');
const [results, setResults] = useState([]);
const [partialResults, setPartialResults] = useState([]); useEffect(() => {
const readToken = localStorage.getItem('readingSession'); if (Authorize) {
}
}, []);
useEffect(() => { useEffect(() => {
Voice.onSpeechStart = onSpeechStartHandler; Voice.onSpeechStart = onSpeechStartHandler;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment