Projet

Général

Profil

0004-misc-remove-explicit-handling-of-account-confirmatio.patch

Frédéric Péters, 18 janvier 2022 17:51

Télécharger (1,95 ko)

Voir les différences:

Subject: [PATCH 4/5] misc: remove explicit handling of account-confirmation
 token expiration (#60665)

 wcs/qommon/ident/password.py | 28 ----------------------------
 1 file changed, 28 deletions(-)
wcs/qommon/ident/password.py
1425 1425
            # XXX: notify admin too
1426 1426

  
1427 1427

  
1428
def handle_expired_tokens(publisher, **kwargs):
1429
    if 'password' not in get_cfg('identification', {}).get('methods', []):
1430
        return
1431
    now = time.time()
1432
    for token_key in tokens.Token.keys():
1433
        try:
1434
            token = tokens.Token.get(token_key, ignore_migration=True)
1435
        except KeyError:
1436
            continue
1437
        if token.type == 'account-confirmation' and now > token.expiration:
1438
            try:
1439
                account = PasswordAccount.get(token.context['username'])
1440
            except KeyError:
1441
                # no such account, unncessary to keep the token
1442
                token.remove_self()
1443
                continue
1444
            if not account.awaiting_confirmation:
1445
                continue
1446
            user = account.get_user()
1447
            account.remove_self()
1448
            # XXX: theorically the user could have been associated with another
1449
            # account, it is ignored.
1450
            if user:
1451
                user.remove_self()
1452
            token.remove_self()
1453

  
1454

  
1455 1428
def register_cronjobs():
1456 1429
    # at 6:00 in the morning, every day
1457 1430
    get_publisher_class().register_cronjob(CronJob(handle_unused_accounts, minutes=[0], hours=[6]))
1458
    get_publisher_class().register_cronjob(CronJob(handle_expired_tokens, minutes=[0], hours=[6]))
1459
-