示例#1
0
def forgot_pwd(username):
    try:
        not_empty(username)
        existed = m_exists(TName, username=username)
        if existed:
            key = random_key()
            redis = get_context().get_redis()
            redis.set(key, username, 60 * 60)
            r = send_mail([username], '找回密码',
                          get_email_content('email_forget_password.html', key=key, username=username))
            return r, 'OK' if r else 'FAIL'
        else:
            return False, 'NO_EXIST'
    except ValueError:
        return False, 'NO_EMPTY'
示例#2
0
def apply_active_account(username):
    try:
        not_empty(username)
        existed = m_exists(TName, username=username)
        if existed:
            key = random_key()
            redis = get_context().get_redis()
            redis.set(key, username, 60 * 60)
            r = send_mail([username], '账号激活',
                          get_email_content('email_active_account.html', key=key, username=username))
            return r, 'OK' if r else 'FAIL'
        else:
            return False, 'NO_EXIST'
    except ValueError:
        return False, 'NO_EMPTY'
示例#3
0
 def forgot_pwd(self, username, host):
     try:
         not_empty(username)
         existed = self.exists(username=username)
         if existed:
             key = random_key()
             redis = get_context().get_redis()
             redis.set(key, username, 60 * 60)
             r = send_mail([username], '找回密码',
                           get_email_content('email_forget_password.html',
                                             host=host,
                                             key=key,
                                             username=username))
             return r, 'OK' if r else 'FAIL'
         else:
             return False, 'NO_EXIST'
     except ValueError:
         return False, 'NO_EMPTY'
示例#4
0
 def apply_active_account(self, username, host):
     try:
         not_empty(username)
         existed = self.exists(username=username)
         if existed:
             key = random_key()
             redis = get_context().get_redis()
             redis.set(key, username, 60 * 60)
             r = send_mail([username], '账号激活',
                           get_email_content('email_active_account.html',
                                             host=host,
                                             key=key,
                                             username=username))
             return r, 'OK' if r else 'FAIL'
         else:
             return False, 'NO_EXIST'
     except ValueError:
         return False, 'NO_EMPTY'