add registration form
This commit is contained in:
parent
4150853588
commit
daab0f063d
|
@ -4,13 +4,14 @@ from wtforms import StringField, SubmitField, TextField, \
|
|||
TextAreaField, PasswordField, IntegerField, FloatField, \
|
||||
DateTimeField, DateField, FormField, BooleanField, \
|
||||
SelectField, Form as NoCsrfForm, SelectMultipleField
|
||||
from wtforms.fields.html5 import EmailField
|
||||
from wtforms.widgets.html5 import NumberInput, DateInput
|
||||
from wtforms.validators import DataRequired, NumberRange, Optional, NoneOf, Length
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class LoginForm(FlaskForm):
|
||||
name = StringField(gettext('User Name'), validators=[DataRequired()])
|
||||
name = StringField(gettext('Username'), validators=[DataRequired()])
|
||||
submit = SubmitField(gettext('Login'))
|
||||
|
||||
|
||||
|
@ -35,3 +36,9 @@ class ConsentForm(FlaskForm):
|
|||
remember = BooleanField(gettext('remember me'))
|
||||
submit = SubmitField()
|
||||
|
||||
|
||||
class RegistrationForm(FlaskForm):
|
||||
username = StringField(gettext('Username'), validators=[DataRequired()])
|
||||
password = PasswordField(gettext('Password'), validators=[DataRequired()])
|
||||
alternative_email = EmailField(gettext('Alternative Email'))
|
||||
submit = SubmitField()
|
||||
|
|
|
@ -318,3 +318,10 @@ class Group(EntryBase):
|
|||
object_classes = ["top"]
|
||||
|
||||
fullname = AttrDef("cn")
|
||||
|
||||
|
||||
class UserSignUp(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
username = db.Column(db.String, nullable=False)
|
||||
password = db.Column(db.String, nullable=False)
|
||||
alternative_email = db.Column(db.String)
|
||||
|
|
|
@ -13,9 +13,10 @@ import logging
|
|||
from urllib.parse import urlparse
|
||||
from base64 import b64decode, b64encode
|
||||
import http
|
||||
import crypt
|
||||
|
||||
from ..model import db, User, SecurityUser
|
||||
from ..form.auth import ConsentForm, LoginForm
|
||||
from ..model import db, User, SecurityUser, UserSignUp
|
||||
from ..form.auth import ConsentForm, LoginForm, RegistrationForm
|
||||
from ..auth_providers import AUTH_PROVIDER_LIST
|
||||
|
||||
|
||||
|
@ -118,3 +119,16 @@ def logout():
|
|||
return redirect(resp.redirect_to)
|
||||
|
||||
|
||||
|
||||
@auth_views.route("/sign_up", methods=["GET", "POST"])
|
||||
def sign_up():
|
||||
form = RegistrationForm()
|
||||
if form.validate_on_submit():
|
||||
user = UserSignUp()
|
||||
user.username = form.data['username']
|
||||
user.password = crypt.crypt(form.data['password'])
|
||||
user.alternative_email = form.data['alternative_email']
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
|
||||
return render_template('auth/sign_up.html.j2', form=form)
|
||||
|
|
|
@ -7,5 +7,7 @@
|
|||
|
||||
{{ render_form(form) }}
|
||||
|
||||
<a href="{{ url_for('.sign_up') }}" class="btn btn-primary">Sign Up</a>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
11
templates/auth/sign_up.html.j2
Normal file
11
templates/auth/sign_up.html.j2
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
{% extends 'auth/base.html.j2' %}
|
||||
|
||||
{% block title %}{{ gettext('Sign Up') }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{{ render_form(form) }}
|
||||
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in a new issue