コード例 #1
0
def change_name():
    """ Renders the change name page and stores the new name """
    form = forms.ChangeName(request.form)
    if form.validate_on_submit():
        current_user.name = form.new_name.data
        current_user.store()
        flash(u'Navn ble oppdatert')
        return redirect(url_for('user'))

    # Show current name in form
    form.new_name.process_data(current_user.name)
    return render_template(
        'user/change_name.html',
        title=u'Endre navn',
        form=form,
        action=url_for('change_name')
    )
コード例 #2
0
def change_password():
    """ Renders the change password page and stores the new password """
    form = forms.ChangePassword(request.form)
    if form.validate_on_submit():
        # Check if password is valid, then hash and store new password
        if utils.verify_password(form.old_password.data, current_user.password):
            current_user.password = utils.encrypt_password(form.new_password.data)
            current_user.store()
            flash(u'Passordet ble endret')
            return redirect(url_for('user'))
        form.old_password.errors.append(u'Feil passord')

    return render_template(
        'user/change_password.html',
        title=u'Endre passord',
        form=form,
        action=url_for('change_password')
    )
コード例 #3
0
def change_email():
    """ Renders the change email page and stores the new email """
    form = forms.ChangeEmail(request.form)
    if form.validate_on_submit():
        # Check if password is valid, then store new password
        if utils.verify_password(form.password.data, current_user.password):
            current_user.email = form.new_email.data
            current_user.store()
            flash(u'E-post adressen ble oppdatert')
            return redirect(url_for('user'))  # Redirect to user settings page
        form.password.errors.append(u'Feil passord')

    return render_template(
        'user/change_email.html',
        title=u'Endre e-post',
        form=form,
        action=url_for('change_email')
    )
コード例 #4
0
def change_playername():
    """ Renders the change Minecraft playername page and stores the playername and its related uuid """
    form = forms.ChangePlayername(request.form)
    if form.validate_on_submit():
        # Check if password is valid, then store playername and uuid
        if utils.verify_password(form.password.data, current_user.password):
            current_user.mojang_playername = form.playername.data
            current_user.mojang_uuid = form.uuid.data
            current_user.store()
            flash(u'Minecraft spillernavnet ble oppdatert')
            return redirect(url_for('user'))
        form.password.errors.append(u'Feil passord')

    else:
        # Show current playername in form
        form.playername.process_data(current_user.mojang_playername)
        form.uuid.process_data(current_user.mojang_uuid)

    return render_template(
        'user/change_playername.html',
        title=u'Endre Minecraft spillernavn',
        form=form,
        action=url_for('change_playername')
    )