add another check on seed inputs

seed-restores
lza_menace 4 years ago
parent f2677349dc
commit d0b573a11c

@ -1,3 +1,4 @@
from re import match as re_match
from flask_wtf import FlaskForm from flask_wtf import FlaskForm
from wtforms import StringField, BooleanField from wtforms import StringField, BooleanField
from wtforms.validators import DataRequired, ValidationError from wtforms.validators import DataRequired, ValidationError
@ -26,5 +27,8 @@ class Restore(FlaskForm):
risks_accepted = BooleanField('I accept the risks:', validators=[DataRequired()], render_kw={"class": "form-control-span"}) risks_accepted = BooleanField('I accept the risks:', validators=[DataRequired()], render_kw={"class": "form-control-span"})
def validate_seed(self, seed): def validate_seed(self, seed):
regex = '^[\w\s]+$'
if bool(re_match(regex, self.seed.data)) is False:
raise ValidationError('Invalid seed provided; must be alphanumeric characters only')
if len(self.seed.data.split()) != 25: if len(self.seed.data.split()) != 25:
raise ValidationError("Invalid seed provided; must be standard Wownero 25 word format") raise ValidationError("Invalid seed provided; must be standard Wownero 25 word format")

Loading…
Cancel
Save