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


Python User.is_exist方法代码示例

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


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

示例1: fun_invite_reg

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import is_exist [as 别名]
def fun_invite_reg(email, pwd, sex, name):
    tmp = User.is_exist(email=email)
    if tmp is True:
        return [1,'邮箱已经被注册!']
    AFW_Group = BasicGroup(_id=AFWConfig.afewords_group_id)
    tmp_email = email.replace(r'.', r'#')
    if AFW_Group.invitation_lib[tmp_email] is None:
        return [1, '很抱歉您并未被邀请!']
    af_pwd = encrypt(pwd)
    af_random = random_string(20)
    token = unicode((af_pwd + af_random), "utf-8")
    usr = User()
    usr.set_propertys(**{'email':email, 'sex':sex, 'name':name, 'token':token, 'domain':unicode(usr._id)})
    tmp_avatar = usr.avatar
    tmp_avatar.thumb_name = '/static/avatar/small/afewords-user.jpg'

    #print 'beta.afewords.com/check?email=', email, '&token=',token
    mail_ok, mail_info = send_mail_reg(email, token, name)
    if mail_ok == 1:
        logging.error('+'*30) 
        logging.error('Email send Failed')
        logging.error('%s %s %s' % (email, token, name))
        logging.error('+'*30)
        return [1,'验证邮件发送失败!']
    else:
        return [0, '']
开发者ID:deju,项目名称:afw_old,代码行数:28,代码来源:AF_LoginTool.py

示例2: user_reg

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import is_exist [as 别名]
def user_reg(email, password, sex, name):
    from afconfig import af_conf
    email = email.lower()
    if User.is_exist({'email':email}):
        return 6 #'existed user'
    if af_conf['needinvite']:
        if not Invitation.is_exist({'email':email}):
            return 7 #'not invited'
    password = encrypt(password)
    token = unicode(random_string(20), 'utf-8')
    usr = User(attrs={'email':email})
    doc = {
        'sex' : sex,
        'name' : name,
        'password' : password,
        'token' : token,
        'domain' : usr.uid,
        'account_status' : 'unverified',
    }
    usr.set_propertys(**doc)
    
    m_status = email_verification(usr)
    if m_status is False:
        logging.error('+'*30) 
        logging.error('Email send Failed')
        logging.error('%s %s %s' % (email, token, name))
        logging.error('+'*30)
        return 8 #'mail error'
    return 0
开发者ID:Earthson,项目名称:afewords_base,代码行数:31,代码来源:user_utils.py

示例3: fun_new_domain

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import is_exist [as 别名]
def fun_new_domain(user, domain):
    if domain == user.domain:
        return [1, '后缀与之前相同!']
    tmp = User.is_exist(domain=domain)
    if tmp is True:
        return [1, '后缀已经被使用!']
    user.domain = domain
    return [0, '']
开发者ID:deju,项目名称:afw_old,代码行数:10,代码来源:AF_LoginTool.py

示例4: post

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import is_exist [as 别名]
 def post(self):
     from user import User
     handler_para = UserDomainSettingPara(self)
     handler_json = UserDomainSettingJson(self)
     usr = self.current_user 
     if not handler_para.domain_verify():
         handler_json.by_status(2)
         handler_json.write()
         return #invalid domain
     if User.is_exist({'domain':handler_para['domain']}) or \
             User.by_id(handler_para['domain']) is not None or \
             User.is_exist({'email':handler_para['domain']}):
         handler_json.by_status(1)
         handler_json.write()
         return #already exist
     usr.domain = handler_para['domain']
     handler_json.by_status(0)
     handler_json.write()
     return
开发者ID:Earthson,项目名称:afewords_base,代码行数:21,代码来源:settinguserhandlers.py

示例5: fun_repeat_mail

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import is_exist [as 别名]
def fun_repeat_mail(email):
    tmp = User.is_exist(email=email)
    if tmp is False:
        return [1,'用户不存在!']
    try:
        user = User(email=email)
        if user.token == '' or user.token is None:
            return [1, '您已经验证成功,可以登录或者重置密码!']
    except Exception, e:
        return [1, '用户不存在!']
开发者ID:deju,项目名称:afw_old,代码行数:12,代码来源:AF_LoginTool.py

示例6: fun_check

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import is_exist [as 别名]
def fun_check(email, token, kind):
    
    tmp = User.is_exist(email=email)
    if tmp is False:
        return [1,'用户不存在!']
    usr = User(email=email)
    if usr.token == token:
        usr.password = token[:40]
        usr.token = ''
        try:
            AFW_Group = BasicGroup(_id=AFWConfig.afewords_group_id)
            usr.follow_group(AFW_Group)
        except Exception:
            logging.error(traceback.format_exc())
        return [0,'']
    if kind == "mail":
        return [1, "抱歉,邮箱验证失败!"]
    else:
        return [1, "抱歉,密码重置失败!"]
开发者ID:deju,项目名称:afw_old,代码行数:21,代码来源:AF_LoginTool.py

示例7: fun_login

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import is_exist [as 别名]
def fun_login(email, pwd):
    tmp = User.is_exist(email=email)
    if tmp is False:
        return [1,'5','']
    usr = User(email=email)
    af_pwd = encrypt(pwd)
    db_pwd, db_id = usr.get_propertys(*('password', '_id'))
    #print db_id, type(db_id), type(db_pwd)
    db_id = str(db_id)
    db_avatar = usr.avatar
    if db_pwd == '':
        return ['0','/check', db_id]
    if af_pwd == db_pwd:
        if db_avatar.file_name == '':
            return ['0', '/settings-avatar', db_id]
        else:
            return ['0','/home', db_id]  
    else:
        return [1, '4', '']
开发者ID:deju,项目名称:afw_old,代码行数:21,代码来源:AF_LoginTool.py

示例8: fun_reset

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import is_exist [as 别名]
def fun_reset(email, pwd):
    tmp = User.is_exist(email=email)
    if tmp is False:
        return [1, '邮箱尚未注册!']

    af_pwd = encrypt(pwd)
    af_random = random_string(20)
    token = unicode((af_pwd + af_random), "utf-8")

    user = User(email=email)
    user.token = token
    mail_ok, mail_info = send_mail_reset(email, token, user.name)
    if mail_ok == 1:
        logging.error('+'*30) 
        logging.error('Email send Failed')
        logging.error('%s %s %s' % (email, token, user.name))
        logging.error('+'*30)
        return [1, '重置密码邮件发送错误!']
    else:
        return [0, '']
开发者ID:deju,项目名称:afw_old,代码行数:22,代码来源:AF_LoginTool.py

示例9: fun_reg

# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import is_exist [as 别名]
def fun_reg(email, pwd, sex, name):
    # encrypt the password and token
    tmp = User.is_exist(email=email)
    if tmp is True:
        return [1,'邮箱已经被注册!']
    
    af_pwd = encrypt(pwd)
    af_random = random_string(20)
    token = unicode((af_pwd + af_random), "utf-8")
    usr = User()
    usr.set_propertys(**{'email':email, 'sex':sex, 'name':name, 'token':token, 'domain':unicode(usr._id)})
    tmp_avatar = usr.avatar
    tmp_avatar.thumb_name = '/static/avatar/small/afewords-user.jpg'

    #print 'beta.afewords.com/check?email=', email, '&token=',token
    mail_ok, mail_info = send_mail_reg(email, token, name)
    if mail_ok == 1:
        logging.error('+'*30) 
        logging.error('Email send Failed')
        logging.error('%s %s %s' % (email, token, name))
        logging.error('+'*30)
        return [1,'验证邮件发送失败!']
    else:
        return [0, '']
开发者ID:deju,项目名称:afw_old,代码行数:26,代码来源:AF_LoginTool.py


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