# Path: boilerplate/models.py
# class User(User):
# class LogVisit(ndb.Model):
# class LogEmail(ndb.Model):
# class SocialUser(ndb.Model):
#     def get_by_email(cls, email):
#     def create_resend_token(cls, user_id):
#     def validate_resend_token(cls, user_id, token):
#     def delete_resend_token(cls, user_id, token):
#     def get_social_providers_names(self):
#     def get_social_providers_info(self):
#     def get_by_user(cls, user):
#     def get_by_user_and_provider(cls, user, provider):
#     def get_by_provider_and_uid(cls, provider, uid):
#     def check_unique_uid(cls, provider, uid):
#     def check_unique_user(cls, provider, user):
#     def check_unique(cls, user, provider, uid):
#     def open_id_providers():
#     PROVIDERS_INFO = { # uri is for OpenID only (not OAuth)
#         'google': {'name': 'google', 'label': 'Google', 'uri': 'gmail.com'},
#         'github': {'name': 'github', 'label': 'Github', 'uri': ''},
#         'facebook': {'name': 'facebook', 'label': 'Facebook', 'uri': ''},
#         'linkedin': {'name': 'linkedin', 'label': 'LinkedIn', 'uri': ''},
#         'myopenid': {'name': 'myopenid', 'label': 'MyOpenid', 'uri': 'myopenid.com'},
#         'twitter': {'name': 'twitter', 'label': 'Twitter', 'uri': ''},
#         'yahoo': {'name': 'yahoo', 'label': 'Yahoo!', 'uri': 'yahoo.com'},
#     }


import logging
import re
import traceback
import sys
import webapp2
from google.appengine.api import users as googleusers
from google.appengine.api.users import NotAllowedError
from webapp2_extras import jinja2
from webapp2_extras import auth
from webapp2_extras import sessions
from google.appengine.api import taskqueue
from boilerplate import models
from boilerplate.lib import utils, i18n
from babel import Locale
        return self.auth.get_user_by_session()

    @webapp2.cached_property
    def user_id(self):
        return str(self.user['user_id']) if self.user else None

    @webapp2.cached_property
    def user_key(self):
        if self.user:
            user_info = models.User.get_by_id(long(self.user_id))
            return user_info.key
        return  None

    @webapp2.cached_property
    def username(self):
        if self.user:
            try:
                user_info = models.User.get_by_id(long(self.user_id))
                return str(user_info.username)
            except AttributeError, e:
                # avoid AttributeError when the session was delete from the server
                logging.error(e)
                self.auth.unset_session()
                self.redirect_to('home')
        return  None

    @webapp2.cached_property
    def email(self):
        if self.user:
            try:

# Path: boilerplate/models.py
# class User(User):
# class LogVisit(ndb.Model):
# class LogEmail(ndb.Model):
# class SocialUser(ndb.Model):
#     def get_by_email(cls, email):
#     def create_resend_token(cls, user_id):
#     def validate_resend_token(cls, user_id, token):
#     def delete_resend_token(cls, user_id, token):
#     def get_social_providers_names(self):
#     def get_social_providers_info(self):
#     def get_by_user(cls, user):
#     def get_by_user_and_provider(cls, user, provider):
#     def get_by_provider_and_uid(cls, provider, uid):
#     def check_unique_uid(cls, provider, uid):
#     def check_unique_user(cls, provider, user):
#     def check_unique(cls, user, provider, uid):
#     def open_id_providers():
#     PROVIDERS_INFO = { # uri is for OpenID only (not OAuth)
#         'google': {'name': 'google', 'label': 'Google', 'uri': 'gmail.com'},
#         'github': {'name': 'github', 'label': 'Github', 'uri': ''},
#         'facebook': {'name': 'facebook', 'label': 'Facebook', 'uri': ''},
#         'linkedin': {'name': 'linkedin', 'label': 'LinkedIn', 'uri': ''},
#         'myopenid': {'name': 'myopenid', 'label': 'MyOpenid', 'uri': 'myopenid.com'},
#         'twitter': {'name': 'twitter', 'label': 'Twitter', 'uri': ''},
#         'yahoo': {'name': 'yahoo', 'label': 'Yahoo!', 'uri': 'yahoo.com'},
#     }


# Path: boilerplate/lib/basehandler.py
import logging
import re
import traceback
import sys
import webapp2
from google.appengine.api import users as googleusers
from google.appengine.api.users import NotAllowedError
from webapp2_extras import jinja2
from webapp2_extras import auth
from webapp2_extras import sessions
from google.appengine.api import taskqueue
from boilerplate import models
from boilerplate.lib import utils, i18n
from babel import Locale

        return self.auth.get_user_by_session()

    @webapp2.cached_property
    def user_id(self):
        return str(self.user['user_id']) if self.user else None

    @webapp2.cached_property
    def user_key(self):
        if self.user:
            user_info = models.User.get_by_id(long(self.user_id))
            return user_info.key
        return  None

    @webapp2.cached_property
    def username(self):
        if self.user:
            try:
                user_info = models.User.get_by_id(long(self.user_id))
                return str(user_info.username)
            except AttributeError, e:
                # avoid AttributeError when the session was delete from the server
                logging.error(e)
                self.auth.unset_session()
                self.redirect_to('home')
        return  None

    @webapp2.cached_property
    def email(self):
        if self.user:
            try:

                user_info = models.User.get_by_id(long(self.user_id))