Beispiel #1
0
    def render_POST(self, request):
        session = IUserSession(request.getSession())

        user = User.login(request.args["email"][0],
                          request.args["password"][0])
        if user:
            session.set_user(user)
        else:
            return redirectTo("login", request)

        return redirectTo("/", request)
Beispiel #2
0
    def render_GET(self, request):
        user_session = IUserSession(request.getSession())

        user = user_session.get_user()
        if user:
            #user_session.email = "foo"
            return jinja.get_template("index.html").render(
                user=user).encode("utf8")
        else:
            num_users = User.select().count()
            if num_users == 0:
                return redirectTo("signup", request)
            else:
                return redirectTo("login", request)
Beispiel #3
0
    def render_POST(self, request):
        session = IUserSession(request.getSession())

        if request.args["password"][0] != request.args["confirm"][0]:
            return redirectTo("signup", request)

        user = User.signup(request.args["email"][0],
                           request.args["password"][0])

        if user:
            session.set_user(user)
        else:
            return redirectTo("signup", request)

        return redirectTo("/", request)
Beispiel #4
0
    def render_GET(self, request):
        num_users = User.select().count()
        session = IUserSession(request.getSession())

        return jinja.get_template("signup.html").render(
            session=session, create_admin=num_users == 0).encode("utf8")