Remove email from register form

This commit is contained in:
pluja 2020-08-24 12:48:44 +02:00
parent 41e78f36f8
commit f3e60200f9
5 changed files with 4 additions and 19 deletions

View File

@ -1,6 +1,6 @@
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField
from wtforms.validators import ValidationError, DataRequired, Email, EqualTo
from wtforms.validators import ValidationError, DataRequired, EqualTo
from app.models import User
@ -21,7 +21,6 @@ class ChannelForm(FlaskForm):
class RegistrationForm(FlaskForm):
username = StringField('Username', validators=[DataRequired()])
email = StringField('Email', validators=[DataRequired(), Email()])
password = PasswordField('Password', validators=[DataRequired()])
password2 = PasswordField(
'Repeat Password', validators=[DataRequired(), EqualTo('password')])
@ -32,10 +31,5 @@ class RegistrationForm(FlaskForm):
if user is not None:
raise ValidationError('Please use a different username.')
def validate_email(self, email):
user = User.query.filter_by(email=email.data).first()
if user is not None:
raise ValidationError('Please use a different email address.')
class EmptyForm(FlaskForm):
submit = SubmitField('Submit')

View File

@ -21,7 +21,6 @@ twitter_association = db.Table('twitter_association',
class User(UserMixin, db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(64), index=True, unique=True)
email = db.Column(db.String(120), index=True, unique=True)
password_hash = db.Column(db.String(128))
posts = db.relationship('Post', backref='author', lazy='dynamic')
@ -34,7 +33,6 @@ class User(UserMixin, db.Model):
def check_password(self, password):
return check_password_hash(self.password_hash, password)
# TWITTER
def follow(self, user):
if not self.is_following(user):
self.followed.append(user)

View File

@ -435,7 +435,7 @@ def register():
if isTwitterUser(form.username.data):
flash('This is username is taken! Choose a different one.')
else:
user = User(username=form.username.data, email=form.email.data)
user = User(username=form.username.data)
user.set_password(form.password.data)
db.session.add(user)
db.session.commit()

View File

@ -16,10 +16,10 @@
<div class="item">
<img src="{{ url_for('static',filename='img/logo.png') }}">
</div>
<a href="{{ url_for('index') }}" class="twitter item">Twitter</a>
{% if current_user.is_anonymous %}
<a href="{{ url_for('login') }}" class="item">Login</a>
{% else %}
<a href="{{ url_for('index') }}" class="twitter item">Twitter</a>
<a href="{{ url_for('search') }}" class="twitter item">Search</a>
<a href="{{ url_for('saved') }}" class="twitter item">Saved</a>
<a href="{{ url_for('youtube') }}" class="youtube item">Youtube</a>

View File

@ -12,13 +12,6 @@
<span style="color: red;">[{{ error }}]</span>
{% endfor %}
</p>
<p>
{{ form.email.label }}<br>
{{ form.email(size=64) }}<br>
{% for error in form.email.errors %}
<span style="color: red;">[{{ error }}]</span>
{% endfor %}
</p>
<p>
{{ form.password.label }}<br>
{{ form.password(size=32) }}<br>