Commit 2254ba58 authored by Lihinikaduwa D.N.R.  's avatar Lihinikaduwa D.N.R.

Logout Done

parent e920b62a
...@@ -4,7 +4,7 @@ import random ...@@ -4,7 +4,7 @@ import random
import os import os
from API.model.colorModel import get_color_activities1, get_color_activities2, get_color_activity_result from API.model.colorModel import get_color_activities1, get_color_activities2, get_color_activity_result
from API.model.readModel import get_reading_activities, save_activity_details, save_session_details from API.model.readModel import get_reading_activities, save_activity_details, save_session_details
from API.model.userModel import getUser, saveUserSession from API.model.userModel import getUser, saveUserSession, logoutUser
from API.model.colorModel import get_color_activities1, get_color_activities2, get_color_activity_result, storeResult from API.model.colorModel import get_color_activities1, get_color_activities2, get_color_activity_result, storeResult
from API.model.readModel import get_reading_activities from API.model.readModel import get_reading_activities
from API.routers.router import funtion_one from API.routers.router import funtion_one
...@@ -123,7 +123,7 @@ def store(): ...@@ -123,7 +123,7 @@ def store():
# Read Function Route (IT) # Read Function Route (IT)
# Loging # Login
@app.route("/login", methods=['POST']) @app.route("/login", methods=['POST'])
def login(): def login():
req = request.get_json() req = request.get_json()
...@@ -151,6 +151,19 @@ def login(): ...@@ -151,6 +151,19 @@ def login():
return make_response(body) return make_response(body)
@app.route("/logout", methods=['POST'])
def logout():
req = request.get_json()
token = req['token']
if(logoutUser(token) == 1):
data = {
"message": "Success",
"status": 200
}
body = jsonify(data)
return make_response(body)
@app.route("/readingSession", methods=['POST']) @app.route("/readingSession", methods=['POST'])
def reading_session(): def reading_session():
req = request.get_json() req = request.get_json()
......
from API.db.dbConnection import get_data from API.db.dbConnection import insert, update_data, get_data
from API.db.dbConnection import insert
from API.util.util import getUUID from API.util.util import getUUID
from datetime import datetime from datetime import datetime
...@@ -18,3 +17,8 @@ def saveUserSession(userId): ...@@ -18,3 +17,8 @@ def saveUserSession(userId):
args = (userId, token, loginTime, 1) args = (userId, token, loginTime, 1)
insert(qry, args) insert(qry, args)
return token return token
def logoutUser(token):
qry = 'UPDATE userSession SET status = 0 WHERE token = "{}"'.format(token)
return update_data(qry)
...@@ -26,10 +26,10 @@ export default function ReadActivityBird() { ...@@ -26,10 +26,10 @@ export default function ReadActivityBird() {
const [readingData, setReadingData] = useState({activity: ''}); const [readingData, setReadingData] = useState({activity: ''});
const readToken = AsyncStorage.getItem('readingSession'); const readToken = AsyncStorage.getItem('readingSession');
useEffect(() => { // useEffect(() => {
if (Authorize) { // 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