コード例 #1
0
ファイル: Auth.py プロジェクト: kphretiq/metro-scooter
    def complete_password_reset(key):
        if request.method == "POST":
            password = request.form["password"]
            password2 = request.form["password2"]
            if not password == password2:
                error = "passwords do not match"
                return render_template("error.html", error=error)
            try:
                temp_auth = TempAuth.query.filter(TempAuth.key==key).first()
                profile = Profile.query.filter(
                        Profile.email==temp_auth.email
                        ).first()

                user = User.query.filter(User.id==profile.id).first()
                username = profile.username
                user.set_and_encrypt_password(password)
                db.session.commit()
            except Exception as error:
                return render_template("error.html", error=error)
            return render_template("auth/login.html", username=username)

        temp_auth = auth_age(TempAuth, key)
        if not temp_auth:
            stale = "Key is too old. Please send another reset email."
            return render_template("auth/login.html", stale = stale)
        return render_template(
                "auth/password-reset.html",
                temp_auth=temp_auth,
                key=key,
                )
コード例 #2
0
ファイル: Auth.py プロジェクト: kphretiq/metro-scooter
    def complete_signup(key):
        if request.method == "POST":
            email = request.form["email"]
            username = request.form["username"]
            password = request.form["password"]

            if User.query.filter(User.username==username).first():
                error = 'User already exists.'
                return render_template("error.html", error=error)

            temp_auth = TempAuth.query.filter(TempAuth.key == key).one()
            error = manifest_user(
                    db, Profile, User, request, "user", email=temp_auth.email)
            if not error:
                return render_template("auth/login.html", username=username)
            return render_template("error.html", error=error)
        temp_auth = auth_age(TempAuth, key)
        if not temp_auth:
            stale = "Key is too old. Please send another signup email."
            return render_template("auth/login.html", stale = stale)
        return render_template("admin/create-user.html", temp_auth=temp_auth)