Beispiel #1
0
    def post(self):
        user_name = self.request.get(self._tplv_username)
        user_password = self.request.get(self._tplv_password)
        
        user = db_model.user.User.get_verified_user(user_name, user_password)

        if user:
            user_id = str(user.key().id())
            self.response.headers.add_header('Set-Cookie', 'user_id=%s; Path=/' % hashing.make_cookie_hash(user_id))
            self.redirect(const_and_params.get_page_welcome())
        else:
            values = {self._tplv_login_error_msg: 'Invalid login'}
            self.render_front(self.set_template_values(values))
Beispiel #2
0
    def post(self):
        user_name = self.request.get(self._tplv_username)
        user_password = self.request.get(self._tplv_password)
        user_verify = self.request.get(self._tplv_verify)
        user_email = self.request.get(self._tplv_email)
        
        newuser, val_errors = db_model.user.User.create_user(user_name, user_password, user_verify, user_email)
        
        if not newuser:
            values = {self._tplv_username: user_name, self._tplv_email: user_email}
            self.set_error_msgs(val_errors, values)
            self.render_front(self.set_template_values(values))
        else:
            newuser.put()
            user_id = str(newuser.key().id())

            self.response.headers.add_header('Set-Cookie', 'user_id=%s; Path=/' % hashing.make_cookie_hash(user_id))
            self.redirect(const_and_params.get_page_welcome())
Beispiel #3
0
# -*- coding: utf-8 -*-
import webapp2

from request_handlers.blog_main_page import BlogMainPage
from request_handlers.newpost_main_page import NewpostMainPage
from request_handlers.permalink_page import PermalinkPage
from request_handlers.signup_page import SignupPage
from request_handlers.welcome_page import WelcomePage
from request_handlers.login_page import LoginPage
from request_handlers.logout_page import LogoutPage

import const_and_params


app = webapp2.WSGIApplication([(const_and_params.get_page_home(), BlogMainPage),
                               (const_and_params.get_page_new_post(), NewpostMainPage),
                               (const_and_params.get_filter_post_permalink(), PermalinkPage),
                               (const_and_params.get_page_signup(), SignupPage),
                               (const_and_params.get_page_welcome(), WelcomePage),
                               (const_and_params.get_page_login(), LoginPage),
                               (const_and_params.get_page_logout(), LogoutPage)], debug=True)


# http://joropi-hello-udacity.appspot.com/blog
# http://joropi-hello-udacity.appspot.com/blog/signup
# http://udacity-cs253.appspot.com/blog