Пример #1
0
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
Пример #2
0
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
Пример #3
0
def invite_other(invitor, invitee_mail):
    from invitation import Invitation
    from mails import send_invite

    invitee_mail = invitee_mail.lower()
    if not Invitation.is_exist({'email':invitee_mail}):
        gcnt = global_info['invitations_count']
        if gcnt >= af_conf['invitation_limit']:
            return 4 #invitation not available, full
        if invitor.invitations <= 0:
            return 1 #your pool is empty
        invi = Invitation(attrs={'email' : invitee_mail})
        invi.date = datetime.now()
        invi.invitor = invitor.email
        global_info.inc('invitations_count')
        invitor.invitations -= 1
    if send_invite(invitor, invitee_mail):
        return 0 #successfull
    return 2 #mail sending error
Пример #4
0
def invite_other(invitor, invitee_mail):
    from invitation import Invitation
    from mails import send_invite

    invitee_mail = invitee_mail.lower()
    if not Invitation.is_exist({'email': invitee_mail}):
        gcnt = global_info['invitations_count']
        if gcnt >= af_conf['invitation_limit']:
            return 4  #invitation not available, full
        if invitor.invitations <= 0:
            return 1  #your pool is empty
        invi = Invitation(attrs={'email': invitee_mail})
        invi.date = datetime.now()
        invi.invitor = invitor.email
        global_info.inc('invitations_count')
        invitor.invitations -= 1
    if send_invite(invitor, invitee_mail):
        return 0  #successfull
    return 2  #mail sending error