Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
BAM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arun Joshua
BAM
Commits
938f4097
Verified
Commit
938f4097
authored
Dec 24, 2020
by
Arun Joshua
Browse files
Options
Downloads
Patches
Plain Diff
Use Emailfield for client side validation
parent
fcb98f96
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bam/forms.py
+26
-8
26 additions, 8 deletions
bam/forms.py
with
26 additions
and
8 deletions
bam/forms.py
+
26
−
8
View file @
938f4097
from
flask_wtf
import
FlaskForm
from
flask_wtf
import
FlaskForm
from
wtforms
import
StringField
,
PasswordField
,
SubmitField
,
BooleanField
from
wtforms
import
PasswordField
,
SubmitField
,
BooleanField
from
wtforms.fields.html5
import
EmailField
from
wtforms.validators
import
DataRequired
,
Length
,
Email
,
EqualTo
,
ValidationError
from
wtforms.validators
import
DataRequired
,
Length
,
Email
,
EqualTo
,
ValidationError
from
bam.models
import
User
from
bam.models
import
User
class
RegistrationForm
(
FlaskForm
):
class
RegistrationForm
(
FlaskForm
):
email
=
StringField
(
"
Email
"
,
validators
=
[
DataRequired
(),
Email
()],
render_kw
=
{
"
placeholder
"
:
"
Enter your email
"
})
email
=
EmailField
(
password
=
PasswordField
(
"
Password
"
,
validators
=
[
DataRequired
()],
render_kw
=
{
"
placeholder
"
:
"
Choose a strong password
"
})
"
Email
"
,
validators
=
[
DataRequired
(),
Email
()],
render_kw
=
{
"
placeholder
"
:
"
Enter your email
"
},
)
password
=
PasswordField
(
"
Password
"
,
validators
=
[
DataRequired
()],
render_kw
=
{
"
placeholder
"
:
"
Choose a strong password
"
},
)
confirm_password
=
PasswordField
(
confirm_password
=
PasswordField
(
"
Confirm Password
"
,
validators
=
[
DataRequired
(),
EqualTo
(
"
password
"
)],
"
Confirm Password
"
,
render_kw
=
{
"
placeholder
"
:
"
Re-enter your password
"
}
validators
=
[
DataRequired
(),
EqualTo
(
"
password
"
)],
render_kw
=
{
"
placeholder
"
:
"
Re-enter your password
"
},
)
)
submit
=
SubmitField
(
"
Sign Up
"
)
submit
=
SubmitField
(
"
Register
"
)
def
validate_email
(
self
,
email
):
def
validate_email
(
self
,
email
):
if
User
.
query
.
filter_by
(
email
=
email
.
data
).
first
():
if
User
.
query
.
filter_by
(
email
=
email
.
data
).
first
():
...
@@ -20,7 +30,15 @@ class RegistrationForm(FlaskForm):
...
@@ -20,7 +30,15 @@ class RegistrationForm(FlaskForm):
class
LoginForm
(
FlaskForm
):
class
LoginForm
(
FlaskForm
):
email
=
StringField
(
"
Email
"
,
validators
=
[
DataRequired
(),
Email
()],
render_kw
=
{
"
placeholder
"
:
"
bookmaster@bam.com
"
})
email
=
EmailField
(
password
=
PasswordField
(
"
Password
"
,
validators
=
[
DataRequired
()],
render_kw
=
{
"
placeholder
"
:
"
masterofbooks
"
})
"
Email
"
,
validators
=
[
DataRequired
(),
Email
()],
render_kw
=
{
"
placeholder
"
:
"
bookmaster@bam.com
"
},
)
password
=
PasswordField
(
"
Password
"
,
validators
=
[
DataRequired
()],
render_kw
=
{
"
placeholder
"
:
"
masterofbooks
"
},
)
remember
=
BooleanField
(
"
Remember Me
"
)
remember
=
BooleanField
(
"
Remember Me
"
)
submit
=
SubmitField
(
"
Login
"
)
submit
=
SubmitField
(
"
Login
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment