当前位置: 首页>>代码示例>>Python>>正文


Python User.find_user_by_email方法代码示例

本文整理汇总了Python中model.user.User.find_user_by_email方法的典型用法代码示例。如果您正苦于以下问题:Python User.find_user_by_email方法的具体用法?Python User.find_user_by_email怎么用?Python User.find_user_by_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.user.User的用法示例。


在下文中一共展示了User.find_user_by_email方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_user

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import find_user_by_email [as 别名]
def get_user(headers):
    current_user = get_endpoints_current_user(raise_unauthorized=False)
    user = None
    if current_user is None:
        credential_pair = get_credential(headers)
        email = credential_pair[0]
        validate_email(email)
        User.authenticate(credential_pair[0], md5(credential_pair[1]))
        user = User.find_user_by_email(email)
    else:
        user = User.find_user_by_email(current_user.email())
    return user
开发者ID:ignitesol,项目名称:tasks,代码行数:14,代码来源:utils.py

示例2: create_teams

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import find_user_by_email [as 别名]
def create_teams():
    team_key = ""
    app_name = ""
    community_name = ""
    admin_user_email = ""
    other_users_email = []

    app = AppInfo.query().filter(AppInfo.lc_name == app_name.lower()).get()
    if not app:
        appinfo_message = AppInfoMessage()
        appinfo_message.name = app_name
        app = AppInfo.insert(appinfo_message)

    community = Community.getCommunityFromTeamKey(team_key=team_key)
    if not community:
        community_message = CommunityMessage(name=community_name,
                                             team_key=team_key,
                                             team_secret=md5(community_name.lower()))
        community_message.user = UserMessage(user_email=admin_user_email)
        Community.insert(community_message)
        community = Community.getCommunityFromTeamKey(team_key=team_key)

    if community and app:
        if not app.key in community.apps:
            community.apps.append(app.key)
            community.put()

    for user_email in other_users_email:
        user = User.find_user_by_email(email=user_email, team_key=team_key)
        if not user:
            user = User.insert_user(user_email, account_type=team_key, image_url="")
        userrole = UserRole.insert(user, community)
开发者ID:usersource,项目名称:anno,代码行数:34,代码来源:update_schema_handler.py

示例3: get_user_from_request

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import find_user_by_email [as 别名]
def get_user_from_request(user_id=None, user_email=None, team_key=None):
    user = None
    if user_id:
        user = User.get_by_id(user_id)
    elif user_email:
        user = User.find_user_by_email(user_email, team_key)
    return user
开发者ID:usersource,项目名称:anno,代码行数:9,代码来源:utils.py

示例4: forgot_details

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import find_user_by_email [as 别名]
 def forgot_details(self, request):
     email = request.user_email
     validate_email(email)
     if not User.find_user_by_email(email):
         raise endpoints.NotFoundException("Email(" + email + ") doesn't exist.")
         # send reset password email
     return message_types.VoidMessage()
开发者ID:ignitesol,项目名称:tasks,代码行数:9,代码来源:account_api.py

示例5: authenticate

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import find_user_by_email [as 别名]
    def authenticate(self, request):
        email = request.user_email
        validate_email(email)
        team_key = request.team_key
        user = User.find_user_by_email(email, team_key)

        if team_key:
            team_secret = request.team_secret
            validate_team_secret(team_secret)

            display_name = request.display_name
            image_url = request.user_image_url

            if not user:
                user = User.insert_user(email=email, username=display_name, account_type=team_key, image_url=image_url)
                community = Community.getCommunityFromTeamKey(team_key)
                UserRole.insert(user, community)
            elif (display_name != user.display_name) or (image_url != user.image_url):
                User.update_user(user=user, email=email, username=display_name, account_type=team_key, image_url=image_url)
            if not Community.authenticate(team_key, md5(team_secret)):
                raise endpoints.UnauthorizedException("Authentication failed. Team key and secret are not matched.")
        elif user.auth_source == AuthSourceType.ANNO:
            password = request.password
            validate_password(password)
            if not user:
                raise endpoints.NotFoundException("Authentication failed. User account " + email + " doesn't exist.")
            if not User.authenticate(email, md5(password)):
                raise endpoints.UnauthorizedException("Authentication failed. Email and password are not matched.")
        else:
            raise endpoints.ForbiddenException("Account for '%s' is Google or Facebook OAuth account." % email)

        return UserMessage(id=user.key.id(), display_name=user.display_name)
开发者ID:usersource,项目名称:anno,代码行数:34,代码来源:account_api.py

示例6: handle_user

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import find_user_by_email [as 别名]
def handle_user(creator_id):
    current_user = get_endpoints_current_user(raise_unauthorized=False)
    if current_user is None:
        if creator_id is not None:
            user = User.find_user_by_email(creator_id + "@gmail.com")
            if user is None:
                user = User.insert_user(email=creator_id + "@gmail.com")
        else:
            email = '[email protected]'
            user = User.find_user_by_email(email)
            if user is None:
                user = User.insert_user(email=email)
    else:
        user = User.find_user_by_email(current_user.email())
        if user is None:
            user = User.insert_user(email=current_user.email())
    return user
开发者ID:usersource,项目名称:anno,代码行数:19,代码来源:utils.py

示例7: user_insert

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import find_user_by_email [as 别名]
 def user_insert(self, request):
     email = request.creator_id + "@gmail.com"
     user = User.find_user_by_email(email)
     if user is None:
         User.insert_user(email)
         print "user " + request.creator_id + " was inserted."
     else:
         print "user" + request.creator_id + " already exists."
     return message_types.VoidMessage()
开发者ID:ignitesol,项目名称:tasks,代码行数:11,代码来源:user_api.py

示例8: auth_user

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import find_user_by_email [as 别名]
def auth_user(headers):
    current_user = get_endpoints_current_user(raise_unauthorized=False)
    user = None

    if current_user is None:
        credential_pair = get_credential(headers)

        signinMethod = SignInMethod.ANNO
        team_key = None
        team_secret = None
        display_name = None
        image_url = None

        if len(credential_pair) == 2:
            email, password = credential_pair
        elif len(credential_pair) == 5:
            signinMethod, email, password, team_key, team_secret = credential_pair
        else:
            signinMethod, email, password, team_key, team_secret, display_name, image_url = credential_pair

        validate_email(email)
        user = User.find_user_by_email(email, team_key)

        if signinMethod == SignInMethod.ANNO:
            User.authenticate(email, md5(password))
        elif signinMethod == SignInMethod.PLUGIN:
            if not Community.authenticate(team_key, team_secret):
                 raise endpoints.UnauthorizedException("Incorrect team key or secret")

            display_name = unicode(display_name, "utf-8", "ignore")
            if not user:
                user = User.insert_user(email=email, username=display_name, account_type=team_key, image_url=image_url)
                community = Community.getCommunityFromTeamKey(team_key)
                UserRole.insert(user, community)
            elif (display_name and display_name != user.display_name) or (image_url and image_url != user.image_url):
                User.update_user(user=user, email=email, username=display_name, account_type=team_key, image_url=image_url)
    else:
        user = User.find_user_by_email(current_user.email())

    if user is None:
        raise endpoints.UnauthorizedException("Oops, something went wrong. Please try later.")

    return user
开发者ID:usersource,项目名称:anno,代码行数:45,代码来源:utils.py

示例9: authenticate

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import find_user_by_email [as 别名]
 def authenticate(self, request):
     email = request.user_email
     validate_email(email)
     password = request.password
     validate_password(password)
     user = User.find_user_by_email(email)
     if not user:
         raise endpoints.NotFoundException("Authentication failed. User account " + email + " doesn't exist.")
     if not User.authenticate(email, md5(password)):
         raise endpoints.UnauthorizedException("Authentication failed. User name and password are not matched.")
     return UserMessage(id=user.key.id(), display_name=user.display_name)
开发者ID:ignitesol,项目名称:tasks,代码行数:13,代码来源:account_api.py

示例10: migrate_photo_time_annos

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import find_user_by_email [as 别名]
def migrate_photo_time_annos(cursor=None):
    team_key = 'us.orbe.Reko-Album'
    phototime_app = AppInfo.query().filter(AppInfo.lc_name == 'phototime').get()
    phototime_community = Community.getCommunityFromTeamKey(team_key=team_key)
    anno_list = Anno.query().filter(Anno.app == phototime_app.key).fetch()

    for anno in anno_list:
        anno.community = phototime_community.key
        user_email = anno.creator.get().user_email
        anno.creator = User.find_user_by_email(email=user_email, team_key=team_key).key
        anno.put()
开发者ID:usersource,项目名称:anno,代码行数:13,代码来源:update_schema_handler.py

示例11: user_display_name_get

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import find_user_by_email [as 别名]
 def user_display_name_get(self, request):
     if request.email is None:
         # if no email is provided, get user by oauth.
         user = get_user(self.request_state.headers)
     else:
         # for not login user, get user by the provided email.
         user = User.find_user_by_email(request.email)
     if user is None:
         return UserMessage(display_name='')
     else:
         return UserMessage(display_name=user.display_name)
开发者ID:ignitesol,项目名称:tasks,代码行数:13,代码来源:user_api.py

示例12: forgot_details

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import find_user_by_email [as 别名]
    def forgot_details(self, request):
        user = User.find_user_by_email(request.user_email)

        if user:
            if user.auth_source == AuthSourceType.ANNO:
                validate_email(request.user_email)
                reset_password(user, request.user_email)
            else:
                raise endpoints.ForbiddenException("Account for '%s' is Google or Facebook OAuth account." % request.user_email)
        else:
            raise endpoints.NotFoundException("Email address is not found. Please enter correct email address.")

        return message_types.VoidMessage()
开发者ID:usersource,项目名称:anno,代码行数:15,代码来源:account_api.py

示例13: bind_account

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import find_user_by_email [as 别名]
 def bind_account(self, request):
     current_user = get_endpoints_current_user(raise_unauthorized=True)
     auth_source = request.auth_source
     if auth_source is None:
         auth_source = 'Google'
     email = current_user.email()
     user = User.find_user_by_email(email)
     if user is not None:
         user.auth_source = auth_source
         user.display_name = request.display_name
         user.put()
     else:
         User.insert_user(current_user.email(), request.display_name, auth_source)
     return message_types.VoidMessage()
开发者ID:ignitesol,项目名称:tasks,代码行数:16,代码来源:account_api.py

示例14: bind_account

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import find_user_by_email [as 别名]
 def bind_account(self, request):
     if request.user_email is None:
         raise endpoints.UnauthorizedException("Oops, something went wrong. Please try later.")
     auth_source = request.auth_source
     if auth_source is None:
         auth_source = AuthSourceType.GOOGLE
     email = request.user_email
     user = User.find_user_by_email(email)
     if user is not None:
         user.auth_source = auth_source
         user.display_name = request.display_name
         user.put()
     else:
         User.insert_user(email=email, username=request.display_name)
     return message_types.VoidMessage()
开发者ID:usersource,项目名称:anno,代码行数:17,代码来源:account_api.py

示例15: get_unread_count

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import find_user_by_email [as 别名]
    def get_unread_count(cls, message):
        user = User.find_user_by_email(message.user_email, team_key=message.team_key)
        unread_count = 0
        limit = 20

        if user is not None:
            query = cls.query().filter(cls.user == user.key)
            query = query.filter(ndb.OR(cls.last_read == None, cls.modified != None))
            activity_list = query.fetch()

            for activity in activity_list[0:limit]:
                anno = activity.anno.get()
                if activity.last_read and anno and anno.last_update_time and (activity.last_read < anno.last_update_time):
                    unread_count += 1

        return unread_count
开发者ID:usersource,项目名称:anno,代码行数:18,代码来源:userannostate.py


注:本文中的model.user.User.find_user_by_email方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。