コード例 #1
0
ファイル: ccs_email.py プロジェクト: libzz/amiral
def delMailBox(session_id, login_id):
    from ccs_contact import verifyLoginID
    """
    Will delete the email account and if now redundant, the
    login as well.
    """
    
    #Check values
    verifyLoginID(login_id)
    
    #Check if there is no other account using this login
    if session.getCountOf("SELECT count(l.login_id) from " \
        "logins l left join customers c on l.login_id = " \
        "c.login_id left join admins a on a.login_id = l.login_id where " \
        "c.customer_id IS NULL and admin_id IS NULL AND l.login_id=%s") == 0:
 
        #remove the login (email account will be cascaded)
        sql = "DELETE FROM logins WHERE login_id=%s"
    else:
        #remove the email account (leave the login alone)
        sql = "DELETE FROM email_account WHERE login_id=%s"

    session.execute(sql,(login_id))
    
    return True
コード例 #2
0
ファイル: ccs_email.py プロジェクト: libzz/amiral
def genMailboxPassword(session_id, login_id, owner_id):
    from ccs_contact import verifyLoginID
    """
    Will generate a new password for a login
    """
    session = getSessionE(session_id)

    #Check values
    verifyLoginID(session_id, login_id)
    verifyLoginID(session_id, owner_id)
    
    plain = createPassword(8)
    
    # Encrypt password
    salt = createSalt()
    passwd = crypt.crypt(plain, salt)
    sql = "UPDATE logins SET passwd=%s WHERE login_id=%s"
    session.execute(sql, (passwd, login_id))
    updateShadowPassword(session, login_id, plain)

    # Raise an event if this is the customers login
    if int(login_id) == int(owner_id):
        triggerEvent(session_id, "customerModified", login_id=login_id)

    return plain