Exemplo n.º 1
0
def profile_settings_username(user):

    user_account_update = user_account.profile_acc_update(current_user.info_id)

    form = ProfileUsernameUpdateForm()

    if form.validate_on_submit():

        user = user_account.login(
            [current_user.username, form.oldpassword.data])

        if user:

            user_account_update.username = form.username.data

            db.session.commit()

            flash('Username was successfully updated!', 'success')

            return redirect(
                url_for('linkages.profile_settings_username',
                        user=current_user.username))

        else:

            flash('Wrong password.', 'error')

    else:

        form.username.data = user_account_update.username

    return render_template('/linkages/profile/settings/username.html',
                           title="Linkages",
                           form=form)
Exemplo n.º 2
0
def profile_settings_password(user):

    user_account_update = user_account.profile_acc_update(current_user.info_id)

    form = PasswordUpdateForm()

    if form.validate_on_submit():

        user = user_account.login(
            [current_user.username, form.oldpassword.data])

        if user:

            user_account_update.password = bcrypt.generate_password_hash(
                form.password.data).decode('utf-8')

            db.session.commit()

            flash('Password was successfully updated!', 'success')

            return redirect(
                url_for('linkages.profile_settings_password',
                        user=current_user.username))

        else:

            flash('Wrong password.', 'error')

    return render_template('/linkages/profile/settings/password.html',
                           title="Linkages",
                           form=form)
Exemplo n.º 3
0
def profile_settings_contact(user):

	user_information_update = user_information.profile_info_update(current_user.info_id)
	user_account_update = user_account.profile_acc_update(current_user.info_id)

	form = ProfileContactUpdateForm()

	if form.validate_on_submit():

		user_information_update.address = form.address.data
		user_information_update.telephone = form.telephone.data
		user_information_update.mobile_number = form.mobile.data

		db.session.commit()

		user_account_update.email_address = form.email.data

		db.session.commit()

		flash('Profile was successfully updated!', 'success')

		return redirect(url_for('registered.profile_settings_contact'), user=current_user.username)

	else:

		form.address.data = user_information_update.address
		form.telephone.data = user_information_update.telephone
		form.mobile.data = user_information_update.mobile_number
		form.email.data = user_account_update.email_address

	return render_template('/registered/profile/settings/contact.html', form=form)