예제 #1
0
파일: usersuite.py 프로젝트: strebbin/sipa
def usersuite():
    """Usersuite landing page with user account information
    and traffic overview.
    """
    try:
        userinfo = query_userinfo(current_user.uid)
        userinfo['checksum'] = calculate_userid_checksum(userinfo['id'])
        trafficdata = query_trafficdata(user_id=userinfo['id'])
    except DBQueryEmpty:
        flash(gettext(u"Es gab einen Fehler bei der Datenbankanfrage!"),
              "error")
        return redirect(url_for("index"))

    return render_template("usersuite/index.html",
                           userinfo=userinfo,
                           usertraffic=trafficdata)
예제 #2
0
파일: usersuite.py 프로젝트: strebbin/sipa
def usersuite_change_mac():
    """As user, change the MAC address of your device.
    """
    form = ChangeMACForm()
    userinfo = query_userinfo(current_user.uid)

    if form.validate_on_submit():
        password = form.password.data
        mac = form.mac.data

        try:
            authenticate(current_user.uid, password)
        except PasswordInvalid:
            flash(gettext(u"Passwort war inkorrekt!"), "error")
        else:
            update_macaddress(userinfo['ip'], userinfo['mac'], mac)

            subject = u"[Usersuite] %s hat seine/ihre MAC-Adresse " \
                      u"geändert" % current_user.uid
            message = u"Nutzer %(name)s (%(uid)s) hat seine/ihre MAC-Adresse " \
                      u"geändert.\nAlte MAC: %(old_mac)s\nNeue MAC: %(new_mac)s" % \
                      {'name': current_user.name, 'uid': current_user.uid,
                       'old_mac': userinfo['mac'], 'new_mac': mac}

            if send_mail(current_user.uid + u"@wh2.tu-dresden.de",
                         "*****@*****.**", subject, message):
                flash(gettext(u"MAC-Adresse wurde geändert!"), "success")
                return redirect(url_for('.usersuite'))
            else:
                flash(gettext(u"Es gab einen Fehler beim Versenden der "
                              u"Nachricht. Bitte schicke uns direkt eine E-Mail "
                              u"an [email protected]"), "error")
                return redirect(url_for('.usersuite'))
    elif form.is_submitted():
        flash_formerrors(form)

    old_mac = userinfo['mac']
    return render_template('usersuite/change_mac.html',
                           form=form, old_mac=old_mac)