예제 #1
0
파일: app.py 프로젝트: h-le/fa-starter
def get_likes():
    """Gets verified user's liked songs"""
    id_token = flask.request.headers['Authorization'].split(' ').pop()
    if not firebase.logged_in(id_token):
        return flask.abort(401, 'User not logged in!')
    likes = bigquery.get_likes(id_token)
    return flask.jsonify(likes)
예제 #2
0
파일: app.py 프로젝트: h-le/fa-starter
def delete_like():
    """Deletes song from verified user's list of liked songs."""
    id_token = flask.request.headers['Authorization'].split(' ').pop()
    if not firebase.logged_in(id_token):
        return flask.abort(401, 'User not logged in!')
    like = json.loads(flask.request.args.get('data'))
    unlike = firebase.unlike_song(like)
    return flask.jsonify(unlike)
예제 #3
0
파일: app.py 프로젝트: h-le/fa-starter
def post_like():
    """Adds song to verified user's list of liked songs."""
    id_token = flask.request.headers['Authorization'].split(' ').pop()
    if not firebase.logged_in(id_token):
        return flask.abort(401, 'User not logged in!')
    song = flask.request.get_json()
    like = firebase.like_song(id_token, song)
    return flask.jsonify(like)
예제 #4
0
파일: app.py 프로젝트: h-le/fa-starter
def get_recommendation():
    """Recommends a song via Genius API to the verified user"""
    id_token = flask.request.headers['Authorization'].split(' ').pop()
    if not firebase.logged_in(id_token):
        return flask.abort(401, 'User not logged in!')
    time_of_day = flask.request.args.get('time_of_day')
    likes = bigquery.get_likes(id_token)
    song = bigquery.get_song(time_of_day, likes)
    return flask.jsonify(song)
예제 #5
0
 def test_not_logged_in(self, mock_verify_id_token):
     """Test checking if a user is _not_ logged in"""
     mock_verify_id_token.side_effect = \
         auth.InvalidIdTokenError('InvalidIdTokenError')
     logged_in = firebase.logged_in(self.id_token)
     self.assertFalse(logged_in)
예제 #6
0
 def test_logged_in(self, mock_verify_id_token):
     """Test checking if a user is logged in"""
     mock_verify_id_token.return_value = self.jwt
     logged_in = firebase.logged_in(self.id_token)
     self.assertTrue(logged_in)