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


Python AuthUser.get_by_username方法代码示例

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


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

示例1: login

# 需要导入模块: from apex.models import AuthUser [as 别名]
# 或者: from apex.models.AuthUser import get_by_username [as 别名]
def login(request):
    """ login(request)
    No return value

    Function called from route_url('apex_login', request)
    """
    title = _('You need to login')
    came_from = get_came_from(request)
    if 'local' not in apex_settings('provider_exclude', []):
        if asbool(apex_settings('use_recaptcha_on_login')):
            if apex_settings('recaptcha_public_key') and apex_settings('recaptcha_private_key'):
                LoginForm.captcha = RecaptchaField(
                    public_key=apex_settings('recaptcha_public_key'),
                    private_key=apex_settings('recaptcha_private_key'),
                )
            form = LoginForm(request.POST,
                            captcha={'ip_address': request.environ['REMOTE_ADDR']})
        else:
            form = LoginForm(request.POST)
    else:
        form = None

    velruse_forms = generate_velruse_forms(request, came_from)

    if request.method == 'POST' and form.validate():
        user = AuthUser.get_by_username(form.data.get('username'))
        if user:
            headers = apex_remember(request, user.id)
            return HTTPFound(location=came_from, headers=headers)

    return {'title': title, 'form': form, 'velruse_forms': velruse_forms, \
            'form_url': request.route_url('apex_login'),
            'action': 'login'}
开发者ID:webjunkie01,项目名称:apex,代码行数:35,代码来源:views.py

示例2: search_user

# 需要导入模块: from apex.models import AuthUser [as 别名]
# 或者: from apex.models.AuthUser import get_by_username [as 别名]
def search_user(username):
    user = None
    if '@' in username:
        user = AuthUser.get_by_email(username)
    if not user:
        user = AuthUser.get_by_username(username)
    if not user:
        user = AuthUser.get_by_login(username)
    return user
开发者ID:mobyle2-legacy,项目名称:apex,代码行数:11,代码来源:views.py

示例3: forgot_password

# 需要导入模块: from apex.models import AuthUser [as 别名]
# 或者: from apex.models.AuthUser import get_by_username [as 别名]
def forgot_password(request):
    """ forgot_password(request):
    no return value, called with route_url('apex_forgot_password', request)
    """
    title = _('Forgot my password')

    if asbool(apex_settings('use_recaptcha_on_forgot')):
        if apex_settings('recaptcha_public_key') and apex_settings('recaptcha_private_key'):
            ForgotForm.captcha = RecaptchaField(
                public_key=apex_settings('recaptcha_public_key'),
                private_key=apex_settings('recaptcha_private_key'),
            )
    form = ForgotForm(request.POST, \
               captcha={'ip_address': request.environ['REMOTE_ADDR']})
    if request.method == 'POST' and form.validate():
        """ Special condition - if email imported from OpenID/Auth, we can
            direct the person to the appropriate login through a flash
            message.
        """
        if form.data['email']:
            user = AuthUser.get_by_email(form.data['email'])
            if user.login:
                provider_name = auth_provider.get(user.login[1], 'Unknown')
                flash(_('You used %s as your login provider' % \
                     provider_name))
                return HTTPFound(location=route_url('apex_login', \
                                          request))
        if form.data['username']:
            user = AuthUser.get_by_username(form.data['username'])
        if user:
            timestamp = time.time()+3600
            hmac_key = hmac.new('%s:%s:%d' % (str(user.id), \
                                apex_settings('auth_secret'), timestamp), \
                                user.email).hexdigest()[0:10]
            time_key = base64.urlsafe_b64encode('%d' % timestamp)
            email_hash = '%s%s' % (hmac_key, time_key)
            apex_email_forgot(request, user.id, user.email, email_hash)
            flash(_('Password Reset email sent.'))
            return HTTPFound(location=route_url('apex_login', \
                                                request))
        flash(_('An error occurred, please contact the support team.'))
    return {'title': title, 'form': form, 'action': 'forgot'}
开发者ID:mobyle2-legacy,项目名称:apex,代码行数:44,代码来源:views.py

示例4: validate_username

# 需要导入模块: from apex.models import AuthUser [as 别名]
# 或者: from apex.models.AuthUser import get_by_username [as 别名]
 def validate_username(form, field):
     if AuthUser.get_by_username(field.data) is not None:
         raise validators.ValidationError(_("Sorry that username already exists."))
开发者ID:webjunkie01,项目名称:apex,代码行数:5,代码来源:forms.py


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