Ejemplo n.º 1
0
    def post(self):
        email = self.session['email'] = self.request.get('email', '').lower()
        password = self.request.get('password')

        # Nothing to log in with
        if not email or not password:
            return self.redirect('/signup', 'email and password required')

        # Password matches the user we found with this email
        user = UserProfile.get_by_email(email)
        if user:
            return self.redirect('/signup', 'user already exists')

        user = UserProfile.create(email, password)
        self.session['user_id'] = user.id

        # Failed to login
        self.redirect('/')
Ejemplo n.º 2
0
    def post(self):
        email = self.session['email'] = self.request.get('email', '').lower()
        password = self.request.get('password')

        if self.user:
            return self.redirect('/user', 'already logged in')

        # Nothing to log in with
        if not email or not password:
            return self.redirect('/login', 'missing password')

        # Password matches the user we found with this email
        user = UserProfile.get_by_email(email)
        if user and user.check_password(password):
            self.session['user_id'] = user.id
            return self.redirect('/')

        # Failed to login
        self.redirect('/login', 'user not found')