def login(): password = request.data.get('password', '') userName = request.data.get('userName', '') user = User.get_all().filter(User.userName == userName).first() print(user) if user is not None: response = jsonify({ 'status': 'ok', 'type': 'account', 'userId': user.id, 'currentAuthority': 'admin' }) loggedinuser = user.id session = Session(user.id) session.save() print('saved') return make_response(response), 200 return make_response( jsonify({ 'status': 'error', 'type': 'account', 'currentAuthority': 'guest' })), 200
def currentUser(): session = Session.get_all().first() if session == None: return make_response( jsonify({ 'status': 'ok', 'type': 'account', 'currentAuthority': 'guest' })), 200 print(session.userId) user = User.get_all().filter(User.id == session.userId).first() res = user.serialise() response = jsonify(res) return make_response(response), 200
def currentUser(): session = Session.get_all().first() if session == None: return make_response(jsonify({'status': 'ok', 'type' : 'account', 'currentAuthority': 'guest'})), 200 print (session.userId) user = User.get_all().filter(User.id == session.userId).first() print (user.favourites) res = user.serialise() res['favourites'] = [] for fav in user.favourites: res['favourites'].append(Card.get_all().filter(Card.id == fav.cardId).first().serialise()) response = jsonify(res) return make_response(response), 200
def logout(): Session.delete_all() return make_response(jsonify({'status': 'ok'})), 200