Ignore:
Timestamp:
14 Oct 2012, 21:02:31 (12 years ago)
Author:
Henrik Bettermann
Message:

Dedicated officers should be able to login as student with a temporary password set by the system. This is the first part of its implementation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py

    r9326 r9334  
    2323import re
    2424import sys
     25from datetime import datetime, timedelta
    2526from urllib import urlencode
    2627from zope import schema
     
    230231                return
    231232            # Display appropriate flash message if credentials are correct
    232             # but student has been deactivated.
     233            # but student has been deactivated or a temporary password
     234            # has been set.
    233235            login = self.request.form['form.login']
    234236            if len(login) == 8 and grok.getSite()['students'].has_key(login):
     
    238240                if student.password is not None and \
    239241                    passwordmanager.checkPassword(student.password, password):
     242                    # The student entered valid credentials.
     243                    # First we check if a temporary password has been set.
     244                    delta = timedelta(minutes=10)
     245                    now = datetime.utcnow()
     246                    temp_password_dict = getattr(student, 'temp_password', None)
     247                    if temp_password_dict is not None and \
     248                        now < temp_password_dict.get('timestamp', now) + delta:
     249                        self.flash(
     250                            _('Your account has been temporarily deactivated.'))
     251                        return
     252                    # Now we know that the student is suspended.
    240253                    self.flash(_('Your account has been deactivated.'))
    241254                    return
    242255            self.flash(_('You entered invalid credentials.'))
     256            return
    243257
    244258
     
    919933${e}
    920934
    921 """, mapping = {'a':normalized_filename,
     935Comment by Import Manager:""", mapping = {'a':normalized_filename,
    922936                'b':importer,
    923937                'c':import_mode,
Note: See TracChangeset for help on using the changeset viewer.