Пример #1
0
def signup():
    if request.method == 'GET':
        return render_template("signup.html")

    netid = request.form['netid']
    password = request.form['password']
    name = request.form['name']

    if not netid or not password or not name:
        flash("Please fill all the blanks.")

    if User.get_user(netid):
        flash(u'NetID already exists!')
        return redirect(url_for('signin'))

    User.add_user(netid, password, name)
    flash('Sign up successfully.')
    return redirect(url_for('signin'))
Пример #2
0
def signup():
    netid = request.form.get('netid', '')
    password = request.form.get('password', '')
    name = request.form.get('name', '')

    if not netid:
        return error(Error.EMPTY_NETID, 400)
    if not password:
        return error(Error.EMPTY_PASSWORD, 400)
    if not name:
        return error(Error.EMPTY_NAME, 400)

    if User.get_user(netid):
        return error(Error.NETID_EXISTED, 400)

    user = User.add_user(netid, password, name)
    ret = user.to_dict()
    ret.pop("password")

    return ok({"user": ret})