Example #1
0
 def post(self):
     if not login_using_local():
         return self.error(404)
     email = self.request.get('email')
     password = self.request.get('password')
     continue_to = self.request.get('continue_to', '/')
     
     google_login_url = users.create_login_url(continue_to)
     errors = []
     local_user = UserAuth.gql('WHERE email=:1', email).get()
     if local_user and self.authenticate(local_user, password):
         login_user = local_user.get_user()
         profile = Profile.gql('WHERE user = :1', login_user).get()
         if not profile:
             created, profile = Profile.get_or_create_from_user(login_user)
             if created:
                 self.redirect('/profile/edit')
         return self.redirect(continue_to)
     else:
         errors.append('Login error, please relogin again')
     using_google = login_using_google()
     return self.render('signin.html', locals())
Example #2
0
    def post(self):
        errors = []
        email = self.request.get('email', '')
        user_auth = None
        if not email:
            errors.append('Email cannot be empty')
        else:
            user_auth = UserAuth.gql('WHERE email = :1', email).get()
            if user_auth is None:
                errors.append('Local user of %s not found' % email)

        password = self.request.get('password', '')
        if not password:
            errors.append('Password is empty')
        password2 = self.request.get('password2', '')
        logging.info('%s: %s' % (password2, password))
        if password2 != password:
            errors.append('Password retyped wrong')
        if errors:
            return self.get(errors=errors)
        user_auth.set_password(password)
        self.response.out.write('Password reset ok.')