Exemplo n.º 1
0
def register():
    form = RegistrationForm(request.form)
    if request.method == 'POST' and form.validate(
    ) and not query.user.get_userLogin(
            form.username.data) and not query.user.get_userLogin(
                form.email.data):
        username = html_escape(form.username.data)
        email = html_escape(form.email.data)
        password = pbkdf2_sha256.using(rounds=10000, salt_size=16).hash(
            html_escape(form.password.data))
        query.user.register_user(username, email, password)
        return redirect(url_for('Page.login'))
    return render_template("register.html", form=form)
Exemplo n.º 2
0
def sensor_edit():
    sid = request.form.get('id')
    sname = html_escape(request.form.get('name'))
    print(request.form)
    query.sensor.sensor_edit(sid, sname)
    response = jsonify({'Code': '200 ok'})
    return response
Exemplo n.º 3
0
def reset():
    form = PassResetForm(request.form)
    if request.method == 'POST' and form.validate():
        username = getSessionUsername()
        user = query.user.get_userLogin(username)
        try:
            if user and pbkdf2_sha256.verify(
                    form.password.data,
                    user["password"]) and user["is_active"] == 1:
                new_password = pbkdf2_sha256.using(
                    rounds=10000,
                    salt_size=16).hash(html_escape(form.new_password.data))
                query.user.Updatepassword(username, new_password)
                flash('Your password has been change.')
            else:
                flash('Please check your password and try again.')
        except:
            flash('Please check your password and try again.')
    return render_template("password_reset.html", form=form)
Exemplo n.º 4
0
def room_edit():
    rid = request.form['rid']
    rname = html_escape(request.form['rname'])
    fid = request.form['fid']
    query.building.room_edit(rid, rname, fid)
    return '200 OK EDIT ROOM'
Exemplo n.º 5
0
def room_add():
    rname = html_escape(request.form['rname'])
    fid = request.form['fid']
    query.building.room_add(rname, fid)
    return '200 OK ADD ROOM'
Exemplo n.º 6
0
def notify_token_edit():
    token = html_escape(request.form['token'])
    query.notification.updateNotiToken(session['id'], token)
    return '200 OK EDIT Notify'
Exemplo n.º 7
0
def notify_time_edit():
    unitSec = html_escape(request.form['unitSec'])
    query.notification.updateNotiTime(session['id'], unitSec)
    return '200 OK EDIT Notify'
Exemplo n.º 8
0
def building_edit():
    bid = request.form['bid']
    bname = html_escape(request.form['bname'])
    query.building.building_edit(bid, bname)
    return '200 OK EDIT BUILDING'
Exemplo n.º 9
0
def building_add():
    bname = html_escape(request.form['bname'])
    query.building.building_add(bname)
    return '200 OK ADD BUILDING'
Exemplo n.º 10
0
def floor_edit():
    fid = request.form['fid']
    fname = html_escape(request.form['fname'])
    bid = request.form['bid']
    query.building.floor_edit(fid, fname, bid)
    return '200 OK EDIT FLOOR'
Exemplo n.º 11
0
def floor_add():
    fname = html_escape(request.form['fname'])
    bid = request.form['bid']
    query.building.floor_add(fname, bid)
    return '200 OK ADD FLOOR'