コード例 #1
0
def anon_user_login():
    try:
        user_id = UserService().insert_user('', 'anon', 1, '/static/images/astronaut.png', 'none', 'N')
        jwt = UserService().create_jwt(user_id)
        response = redirect(url_for('index.index'))
        set_access_cookies(response, jwt['access_token'])
        set_refresh_cookies(response, jwt['refresh_token'])
        current_app.logger.info('registered user!')
    except Exception as e:
        print(e)
        response = redirect(url_for('index.index'))
    finally:
        return response
コード例 #2
0
def daily_challenge():
    data = request.get_json()
    userID = get_jwt_identity()
    if (userID is None):
        return auth.anon_user_login()
    user = UserService().get_user(get_jwt_identity()).serialize()
    if (user['logintype'] != 'anon'):
        value = GeneratorService().insert_daily_challenge_submit(data['score'], userID, json.dumps(data['solutiondata']), trimstring(data['name']),
                                                         data['dc_id'], json.dumps(data['playerStateList']))
    else:
        UserService().change_name(userID, trimstring(data['name']))
        value = GeneratorService().insert_daily_challenge_submit(data['score'], userID, json.dumps(data['solutiondata']), trimstring(data['name']),
                                                         data['dc_id'], json.dumps(data['playerStateList']))
    return value
コード例 #3
0
def new_google_login(name,id_token,email,picture,id):
    user = UserService().get_user_by_logintype(id,'google')
    if (user is not None):
        #assign jwt for same user
        jwt = UserService().create_jwt(user.userID)
        response = redirect(url_for('index.index'))
        set_access_cookies(response, jwt['access_token'])
        set_refresh_cookies(response, jwt['refresh_token'])
        return response
    else:
        userID = UserService().insert_user(str(name), 'google', str(id), str(picture), str(email), 'Y')
        jwt = UserService().create_jwt(userID)
        response = redirect(url_for('index.index'))
        set_access_cookies(response, jwt['access_token'])
        set_refresh_cookies(response, jwt['refresh_token'])
        return response
コード例 #4
0
def new_facebook_login(id,username,email,pictureUrl):
    try:
        user = UserService().get_user_by_logintype(id,'facebook')
        if user is None:
            user_id = UserService().insert_user(str(username), 'facebook', str(id),str(pictureUrl), str(email), 'Y')
            jwt = UserService().create_jwt(user_id)
            response = redirect(url_for('index.index'))
            set_access_cookies(response, jwt['access_token'])
            set_refresh_cookies(response, jwt['refresh_token'])
            current_app.logger.info('registered user!')
        else:
            jwt = UserService().create_jwt(user.userID)
            response = redirect(url_for('index.index'))
            set_access_cookies(response, jwt['access_token'])
            set_refresh_cookies(response, jwt['refresh_token'])
            current_app.logger.info('already registered user!')
    except Exception as e:
        print(e)
        response = redirect(url_for('index.index'))
    finally:
        return response
コード例 #5
0
def customuser1292834():
    jwt = UserService().create_jwt(35)
    response = redirect(url_for('index.index'))
    set_access_cookies(response, jwt['access_token'])
    set_refresh_cookies(response, jwt['refresh_token'])
    return response
コード例 #6
0
ファイル: PageInfo.py プロジェクト: Kwazinator/robotsevolved
def index():
    get_games_data_value = get_games_data(50,0)
    userID = get_jwt_identity()
    user = None
    gamesview = None
    solutionsview = None
    puzzlerushview = None
    dc_movesList = None
    dc_playerList = None
    dc_moves=None
    loggedin = 'No'
    learngameslist = get_learned_games()
    dailychallengelist = json.dumps(GeneratorService().get_daily_puzzles())
    dc_id = GeneratorService().get_daily_challenge_id()
    dchighscores = json.dumps(GeneratorService().get_daily_challenge_highscores(dc_id))
    if (userID is not None):
        #gamesview = json.dumps(UserService().get_user_games_view(userID))
        #solutionsview = json.dumps(UserService().get_user_solutions_view(userID))
        #puzzlerushview = json.dumps(UserService().get_user_puzzlerush_view(userID))
        #Start test data
        gamesviewlist = list()
        solutionsview = list()
        gamesviewlist.append(GameService().get_game(2).serialize())
        gamesview = json.dumps(gamesviewlist)
        game1 = GameService().get_game(2).serialize()
        game1["highscore"] = 4
        game1["HSname"] = "Kyle Kwasniewski"
        game1["ProfilePicture"] = "https://www.google.com/url?sa=i&url=https%3A%2F%2Ftowardsdatascience.com%2F3-numpy-image-transformations-on-baby-yoda-c27c1409b411&psig=AOvVaw27J8nyH6FuCgEtiqJp9Y7N&ust=1592512074629000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCJjo5PTXieoCFQAAAAAdAAAAABAD"
        solutionsview.append(game1)
        game2 = GameService().get_game(3).serialize()
        game2["highscore"] = 20
        game2["HSname"] = "DSchultz"
        game2["ProfilePicture"] = "https://www.google.com/url?sa=i&url=https%3A%2F%2Ftowardsdatascience.com%2F3-numpy-image-transformations-on-baby-yoda-c27c1409b411&psig=AOvVaw27J8nyH6FuCgEtiqJp9Y7N&ust=1592512074629000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCJjo5PTXieoCFQAAAAAdAAAAABAD"
        solutionsview.append(game2)
        solutionsview = json.dumps(solutionsview)
        puzzlerushview = {
            "bestscore": 21,
            "averagescoreday": 8.92,
            "averagescoreweek": 6.78,
            "averagescoremonth": 5.92,
            "bestscorepercentile": .7,
            "percentilescoreday": .8,
            "percentilescoreweek": .7,
            "percentilescoremonth": .6,
            "bestaveragediff": 40,
            "averagediffvalday": 26,
            "averagediffvalweek": 19,
            "averagediffvalmonth": 17,
            "percentilediffvalday": .8,
            "percentilediffvalweek": .7,
            "percentilediffvalmonth": .6,
            "bestdiffvalpercentile": .9
        }
        puzzlerushview = json.dumps(puzzlerushview)
        #end test data
        user = UserService().get_user(get_jwt_identity()).serialize()
        loggedin = 'Yes'
        dc_moves = GeneratorService().get_daily_challenge_moves(dc_id,userID)
        gamesview = json.dumps(GameService().get_games_profile_view(userID))
        puzzlerushview = json.dumps(PuzzleRushService().get_puzzle_rush_profile_view(userID))
        solutionsview = json.dumps(GameService().get_solutions_profile_view(userID))
        if dc_moves is not None:
            dc_movesList = dc_moves[0]
            dc_playerList = dc_moves[1]
    return render_template('index.html',dc_playerList=dc_playerList,dc_movesList=dc_movesList,dchighscores=dchighscores,dc_id=dc_id,dailyChallengeGameslist=dailychallengelist,learngameslist=learngameslist, gamesview=gamesview,solutionsview=solutionsview,puzzlerushview=puzzlerushview,loggedin=loggedin, user=json.dumps(user), gamedata=json.dumps({'uri': ''}), highscores='[]', highscoreslist=json.dumps(get_games_data_value[1]), uri='',gameslist=json.dumps(get_games_data_value[0]))
コード例 #7
0
ファイル: PageInfo.py プロジェクト: Kwazinator/robotsevolved
def userDelete():
    data = request.get_json()
    UserService().delete_user(data['userID'])
    return 'OK'
コード例 #8
0
ファイル: PageInfo.py プロジェクト: Kwazinator/robotsevolved
def userCreate():
    data = request.get_json()
    UserService().insert_user(data['userId'], data['logintype'], data['accountId'], data['profilePicture'], data['email'])
    return 'OK'