예제 #1
0
def profile_settings():
    user = g.user

    form = ProfileSettingsForm(
        full_name=(user.full_name or '').strip(),
        email=user.email
    )

    if form.validate_on_submit():
        full_name = form.full_name.data
        email = form.email.data

        user.full_name = full_name

        if email != user.email:
            send_verify_email(email, user)

            flash('Verification email sent to %s' % email, 'success')
        else:
            flash('Profile saved!', 'success')

        user.save()

    unverified_email = _get_unverified_email(user)

    template_vars = {
        'form': form,
        'unverified_email': unverified_email,
        'player': user.player,
        'active_option': 'profile'
    }

    return render_template('settings/profile.html', **template_vars)
예제 #2
0
def profile_settings():
    user = g.user

    form = ProfileSettingsForm(full_name=(user.full_name or '').strip(),
                               email=user.email)

    if form.validate_on_submit():
        full_name = form.full_name.data
        email = form.email.data

        user.full_name = full_name

        if email != user.email:
            send_verify_email(email, user)

            flash('Verification email sent to %s' % email, 'success')
        else:
            flash('Profile saved!', 'success')

        user.save()

    unverified_email = _get_unverified_email(user)

    template_vars = {
        'form': form,
        'unverified_email': unverified_email,
        'player': user.player,
        'active_option': 'profile'
    }

    return render_template('settings/profile.html', **template_vars)
예제 #3
0
def register():
    uuid = request.form.get('uuid')
    email = request.form.get('email')
    username = request.form.get('username')

    player = Player.query.filter_by(uuid=uuid).first()
    if not player:
        return jsonify({
            'err': 1,
            'message': 'Please try again later'
        })

    user = User.query.filter_by(player=player).first()
    if user and user.email:
        return jsonify({
            'err': 1,
            'message': 'You are already registered!'
        })

    if not h.is_valid_email(email):
        return jsonify({
            'err': 1,
            'message': 'Not a valid email address'
        })

    other_user = User.query.filter_by(email=email).first()
    if other_user:
        return jsonify({
            'err': 1,
            'message': 'Email already in use'
        })

    email_tokens = EmailToken.query.filter_by(uuid=uuid)
    for email_token in email_tokens:
        db.session.delete(email_token)

    # old-style user without an email, just let them verify an email
    if user:
        send_verify_email(email, user)
    else:
        send_creation_email(email, uuid, username)

    total_time = libplayer.get_total_player_time(player.id)
    if total_time < app.config['MINIMUM_REGISTER_PLAYER_TIME']:
        rollbar.report_message('Player creating user account super quickly', level='error', request=request)
        AuditLog.create(
            AuditLog.QUICK_USER_CREATE,
            player_id=player.id,
            username=player.username,
            commit=True
        )

    return jsonify({
        'err': 0,
        'message': 'Email sent! Check your inbox for further instructions'
    })
예제 #4
0
def resend_verification_email():
    user = g.user

    unverified_email = _get_unverified_email(user)

    if unverified_email:
        send_verify_email(unverified_email, user)

        flash('Verification email sent to %s' % unverified_email, 'success')
    else:
        flash('No unverified email', 'warning')

    return redirect(url_for('profile_settings'))
예제 #5
0
def resend_verification_email():
    user = g.user

    unverified_email = _get_unverified_email(user)

    if unverified_email:
        send_verify_email(unverified_email, user)

        flash('Verification email sent to %s' % unverified_email, 'success')
    else:
        flash('No unverified email', 'warning')

    return redirect(url_for('profile_settings'))
예제 #6
0
def register():
    uuid = request.form.get('uuid')
    email = request.form.get('email')
    username = request.form.get('username')

    player = Player.query.filter_by(uuid=uuid).first()
    if not player:
        return jsonify({'err': 1, 'message': 'Please try again later'})

    user = User.query.filter_by(player=player).first()
    if user and user.email:
        return jsonify({'err': 1, 'message': 'You are already registered!'})

    if not h.is_valid_email(email):
        return jsonify({'err': 1, 'message': 'Not a valid email address'})

    other_user = User.query.filter_by(email=email).first()
    if other_user:
        return jsonify({'err': 1, 'message': 'Email already in use'})

    email_tokens = EmailToken.query.filter_by(uuid=uuid)
    for email_token in email_tokens:
        db.session.delete(email_token)

    # old-style user without an email, just let them verify an email
    if user:
        send_verify_email(email, user)
    else:
        send_creation_email(email, uuid, username)

    total_time = libplayer.get_total_player_time(player.id)
    if total_time < app.config['MINIMUM_REGISTER_PLAYER_TIME']:
        rollbar.report_message('Player creating user account super quickly',
                               level='error',
                               request=request)
        AuditLog.create(AuditLog.QUICK_USER_CREATE,
                        player_id=player.id,
                        username=player.username,
                        commit=True)

    return jsonify({
        'err':
        0,
        'message':
        'Email sent! Check your inbox for further instructions'
    })
예제 #7
0
def register():
    uuid = request.form.get('uuid')
    email = request.form.get('email')
    username = request.form.get('username')

    player = Player.query.filter_by(uuid=uuid).first()
    if not player:
        return jsonify({
            'err': 1,
            'message': 'Please try again later'
        })

    user = User.query.filter_by(player=player).first()
    if user and user.email:
        return jsonify({
            'err': 1,
            'message': 'You are already registered!'
        })

    if not h.is_valid_email(email):
        return jsonify({
            'err': 1,
            'message': 'Not a valid email address'
        })

    other_user = User.query.filter_by(email=email).first()
    if other_user:
        return jsonify({
            'err': 1,
            'message': 'Email already in use'
        })

    email_tokens = EmailToken.query.filter_by(uuid=uuid)
    for email_token in email_tokens:
        db.session.delete(email_token)

    # old-style user without an email, just let them verify an email
    if user:
        send_verify_email(email, user)
    else:
        send_creation_email(email, uuid, username)

    return jsonify({
        'err': 0,
        'message': 'Email sent! Check your inbox for further instructions'
    })