def get(self):
        """
        GET request handler that displays the homepage.

        GET request handler that renders the application home page for
        non-authenticated visitors and redirects authenticated users to the
        profile sync user page. 
        """
        # Check to see if user is authenticated
        cur_user = users.get_current_user()
        if cur_user:

            # If the user is valid and logged in
            if util.check_email(cur_user.email()):
                self.redirect("/sync_user")
                return

            flash_message = account_facade.get_flash_message(cur_user.email())

        else:

            flash_message = None

        # Render page
        template = jinja_environment.get_template("home.html")
        content = template.render(
            {
                "login_url": users.create_login_url("/sync_user"),
                "flash_message": flash_message
            }
        )
        self.response.out.write(content)
    def get(self):
        """
        GET request handler that ensures a user has a models.UserInfo record.

        GET request handler that checks that a user has a models.UserInfo
        record, creating it if it does not already exit. All users are then
        redirected to the page specified by util.get_user_home.
        """
        cur_user = users.get_current_user()
        target_email = cur_user.email()

        if not util.check_email(target_email):
            account_facade.set_flash_message(
                target_email,
                constants.FLASH_MSG_TYPE_ERR,
                constants.FLASH_MSG_INVALID_EMAIL
            )
            self.redirect(constants.HOME_URL)
        else:
            account_facade.ensure_user_info(cur_user)
            self.redirect(util.get_user_home(cur_user))
Example #3
0
#/usr/bin/env python
"""
  test script to check email
"""

__author__ = "Takahiro Matsumoto"
__date__ = "2018-12-11"

import util

if __name__ == "__main__":

    print("### test to check email ###")

    valid_email = "*****@*****.**"
    print("valid_email = ", valid_email, ", result=",
          util.check_email(valid_email))

    invalid_email = "[email protected]."
    print("invalid_email = ", invalid_email, ", result=",
          util.check_email(invalid_email))