Skip to content
Snippets Groups Projects
Commit 34f8688f authored by Benjamin Iorns's avatar Benjamin Iorns
Browse files

Recaptcha added to contact for extra security. It doesn't work on Localhost...

Recaptcha added to contact for extra security. It doesn't work on Localhost though, so it needs to be tested in production.
parent 6d9d9eef
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,13 @@ app.config['MAIL_USE_TLS'] = True ...@@ -21,6 +21,13 @@ app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USE_SSL'] = False app.config['MAIL_USE_SSL'] = False
mail = Mail(app) mail = Mail(app)
# recaptcha
app.config['RECAPTCHA_USE_SSL']= False
app.config['RECAPTCHA_PUBLIC_KEY']= os.getenv("SITE_KEY")
app.config['RECAPTCHA_PRIVATE_KEY']= os.getenv("SECRET_KEY")
app.config['RECAPTCHA_OPTIONS']= {'theme':'black'}
basedir = os.path.abspath(os.path.dirname(__file__)) basedir = os.path.abspath(os.path.dirname(__file__))
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + os.path.join(basedir, 'portfolio.db') app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + os.path.join(basedir, 'portfolio.db')
db = SQLAlchemy(app) db = SQLAlchemy(app)
......
from flask_wtf import FlaskForm from flask_wtf import FlaskForm, RecaptchaField
from wtforms import StringField, TextAreaField, SubmitField from wtforms import StringField, TextAreaField, SubmitField
from wtforms.validators import DataRequired, Email, Length from wtforms.validators import DataRequired, Email, Length
...@@ -7,3 +7,5 @@ class ContactForm(FlaskForm): ...@@ -7,3 +7,5 @@ class ContactForm(FlaskForm):
email = StringField('Email', validators=[DataRequired(), Email()]) email = StringField('Email', validators=[DataRequired(), Email()])
message = TextAreaField('Message', validators=[DataRequired(), Length(min=10)]) message = TextAreaField('Message', validators=[DataRequired(), Length(min=10)])
submit = SubmitField('Send') submit = SubmitField('Send')
# The recaptcha doesn't work on localhost. Check it in during hosting.
recaptcha = RecaptchaField()
\ No newline at end of file
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
{{ form.message(cols=30, rows=5)}} {{ form.message(cols=30, rows=5)}}
<br> <br>
{{ form.submit() }} {{ form.submit() }}
{{ form.recaptcha }}
</form> </form>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment