def post(self):
        form = SignupForm(request.form)

        if form.validate_on_submit():
            try:
                self._create_account(form.email.data, form.password.data)
                flash('Signed up! Now log in.')
                return redirect(url_for('auth.login'))
            except Exception as e:
                self.logger.exception(e)
                flash('Error!')
        return render_template("auth/signup.html", form=form)
Exemplo n.º 2
0
def signup():

    form = SignupForm()
    
    if request.method == 'POST':
        if form.validate() == False:
            return render_template("authentication/signup.html", form=form)
        else:
            new_user = User(form.username.data, form.email.data, form.password.data)
            db.session.add(new_user)
            db.session.commit()

            session['email'] = new_user.email
            return "Not found"
        
    elif request.method == 'GET':
        return render_template("authentication/signup.html", form=form)
Exemplo n.º 3
0
def signup():
    form = SignupForm()

    if current_user.is_authenticated:
        return redirect(url_for('authentication.index'))

    if form.validate_on_submit():
        username = form.username.data
        email = form.email.data
        password = form.repeat_password.data

        client = boto3.client('cognito-idp', region_name=Config.REGION)
        try:
            resp = client.sign_up(ClientId=Config.APP_CLIENT_ID,
                                  SecretHash=get_secret_hash(username),
                                  Username=username,
                                  Password=password,
                                  UserAttributes=[{
                                      'Name': "email",
                                      'Value': email
                                  }],
                                  ValidationData=[{
                                      'Name': "email",
                                      'Value': email
                                  }])
            print('Sign up Successfully')
            return redirect(url_for('authentication.confirm_signup'))

        except client.exceptions.UsernameExistsException as e:
            flash('This username already exists')
            return redirect(url_for('authentication.signup'))
        except client.exceptions.InvalidPasswordException as e:
            flash('Password not strong enough')
            return redirect(url_for('authentication.signup'))
        except client.exceptions.UserLambdaValidationException as e:
            flash('This email already exists')
            return redirect(url_for('authentication.signup'))
        except Exception as e:
            flash(e)
            return redirect(url_for('authentication.signup'))

    return render_template('authentication/signup.html',
                           form=form,
                           title='Sign Up')
Exemplo n.º 4
0
def signup():

    form = SignupForm()

    if "email" is session:
        return redirect(url_for("profile"))

    if request.method == "POST":
        if form.validate() == False:
            return render_template("authentication/signup.html", form=form)
        else:
            new_user = User(form.username.data, form.email.data, form.password.data)
            db.session.add(new_user)
            db.session.commit()

            session["email"] = new_user.email
            return "Not found"

    elif request.method == "GET":
        return render_template("authentication/signup.html", form=form)
Exemplo n.º 5
0
def signup():
    form = SignupForm()
    if ('token' in session) and (User.verify_token(session['token'])):
        return redirect(url_for('auth.profile'))
    if request.method == 'POST':
        if form.validate() is False:
            return render_template("authentication/signup.html", form=form)
        else:
            new_user = User(form.username.data,
                            form.email.data,
                            form.password.data,
                            READ_ROLE + COMMENT_ROLE + WRITE_ROLE, 1)
            db.session.add(new_user)
            db.session.commit()
            session['user_id'] = new_user.id
            session['token'] = new_user.generate_token()
            session['email'] = new_user.email
            session['user_name'] = new_user.username
        return redirect(url_for('auth.profile'))
    elif request.method == 'GET':
        return render_template("authentication/signup.html", form=form)
Exemplo n.º 6
0
def signup():

    form = SignupForm()

    if 'email' is session:
        return redirect(url_for('profile'))

    if request.method == 'POST':
        if form.validate() == False:
            return render_template("authentication/signup.html", form=form)
        else:
            new_user = User(form.username.data, form.email.data,
                            form.password.data)
            db.session.add(new_user)
            db.session.commit()

            session['email'] = new_user.email
            return "Not found"

    elif request.method == 'GET':
        return render_template("authentication/signup.html", form=form)
 def get(self):
     form = SignupForm(request.form)
     return render_template("auth/signup.html", form=form)