예제 #1
0
파일: cot.py 프로젝트: shish/commentonthis
    def POST(self):
        if session.user.name == "Anonymous":
            raise web.seeother("/dashboard/login")

        function = web.input(function=None).function

        if function == "setpw":
            inp = web.input(password=None, password1=None, password2=None)
            current = model.get_user(name=session.user.name, password=inp.password)
            if not current:
                flash("error", "Current password incorrect")
            elif inp.password1 != inp.password2:
                flash("error", "New passwords don't match")
            else:
                model.set_user_password(session.user.name, inp.password1)
                flash("success", "Password changed")

        if function == "setmailmode":
            inp = web.input(mailmode=None)
            if inp.mailmode in ["none", "daily", "all"]:
                # FIXME: argh at the DB and session not being as one...
                model.set_user_mailmode(session.user.name, inp.mailmode)
                session.user.mailmode = inp.mailmode
                flash("success", "Mail mode set to '%s'" % inp.mailmode)
            else:
                flash("error", "Invalid mail mode")

        raise web.seeother("/settings")
예제 #2
0
파일: cot.py 프로젝트: shish/commentonthis
    def POST(self):
        inp = web.input(name=None, email=None)

        if not inp.name and not inp.email:
            return render.dashboard_reset(error="Missing name or email")

        user = model.get_user(name=inp.name) or model.get_user(email=inp.email)

        if not user or user.name == "Anonymous":
            return render.dashboard_login(error="No user with those details")

        pw = generate_password()
        model.set_user_password(user.name, pw)
        web.sendmail(
            'Comment on This! <*****@*****.**>',
            user.email,
            '[CoT] Password Reset',
            "Your new password is "+pw+
            "\n\nLog in at http://www.commentonthis.net/dashboard/login"+
            "\n\nSee you in a moment!"+
            "\n\n    -- The Comment on This Team"
        )

        return render.dashboard_reset_sent()