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 flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField 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 from app.models import User
@ -21,7 +21,6 @@ class ChannelForm(FlaskForm):
class RegistrationForm(FlaskForm): class RegistrationForm(FlaskForm):
username = StringField('Username', validators=[DataRequired()]) username = StringField('Username', validators=[DataRequired()])
email = StringField('Email', validators=[DataRequired(), Email()])
password = PasswordField('Password', validators=[DataRequired()]) password = PasswordField('Password', validators=[DataRequired()])
password2 = PasswordField( password2 = PasswordField(
'Repeat Password', validators=[DataRequired(), EqualTo('password')]) 'Repeat Password', validators=[DataRequired(), EqualTo('password')])
@ -32,10 +31,5 @@ class RegistrationForm(FlaskForm):
if user is not None: if user is not None:
raise ValidationError('Please use a different username.') 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): class EmptyForm(FlaskForm):
submit = SubmitField('Submit') submit = SubmitField('Submit')

View File

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

View File

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

View File

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

View File

@ -12,13 +12,6 @@
<span style="color: red;">[{{ error }}]</span> <span style="color: red;">[{{ error }}]</span>
{% endfor %} {% endfor %}
</p> </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> <p>
{{ form.password.label }}<br> {{ form.password.label }}<br>
{{ form.password(size=32) }}<br> {{ form.password(size=32) }}<br>