Esempio n. 1
0
def is_thread_safe_mode():
    cplist = ImsConfiguration.objects.all()
    if not cplist or len(cplist) > 1:
        logger.critical('Error in configuration parameter %s', cplist)

    cp = cplist[0]
    return cp.thread_safe_mode
Esempio n. 2
0
def issue_new_vtoken(name, email, mobile, refer):
    status = tStatus.UNKNOWN_ERROR
    vtoken = None
    issued_token = get_issued_valid_token_for_visitor(mobile)
    status_str = None

    if issued_token:
        vtoken = issued_token
        logger.debug('Valid issued token found for visitor %s : %d',
                     vtoken.issued_to, vtoken.mobile_number)
        status = tStatus.TOKEN_REISSUED
        status_str = 'OLD'

    else:
        vtoken = get_next_vtoken()
        if vtoken:
            vtoken.token_state = ccfg.TokenState.ISSUED.value
            vtoken.issued_on = dt.date.today()
            vtoken.issued_to = name
            vtoken.email_address = email
            vtoken.mobile_number = mobile
            vtoken.refered_by = refer
            vtoken.save()
            logger.info('%s token issued to %d', vtoken.userid, mobile)
            status = tStatus.SUCCESS
            status_str = 'NEW'

        else:
            status = tStatus.TOKEN_EXHAUSTED
            logger.critical('Visitor token exhausted %d', mobile)

    if vtoken:
        sa.send_token(mobile, status_str, vtoken.userid, vtoken.password)
    return status, vtoken
Esempio n. 3
0
def send_token_via_sms():
    cplist = ImsConfiguration.objects.all()
    if not cplist or len(cplist) > 1:
        logger.critical('Error in configuration parameter %s', cplist)

    cp = cplist[0]
    return cp.send_token_via_sms
Esempio n. 4
0
def session_timeout():
    cplist = ImsConfiguration.objects.all()
    if not cplist or len(cplist) > 1:
        logger.critical('Error in configuration parameter %s', cplist)

    cp = cplist[0]
    return cp.session_timeout
Esempio n. 5
0
def otp_max_retries():
    cplist = ImsConfiguration.objects.all()

    if not cplist or len(cplist) > 1:
        logger.critical('Error in configuration parameter %s', cplist)

    cp = cplist[0]
    return cp.otp_max_retries
Esempio n. 6
0
    def handle_visitor(self, request):

        status = tStatus.UNKNOWN_ERROR
        token = None

        otp_dict = visitor_otp

        if otp_dict[self.ss_key]['state'] in self.fsm.keys():
            return self.fsm[otp_dict[self.ss_key]['state']](request)

        else:
            logger.critical('Invalid state for session %s visitor %s',
                            self.ss_key, otp_dict[self.ss_key])
Esempio n. 7
0
def issue_new_itoken(registration_number):

    status = tStatus.UNKNOWN_ERROR
    participant_info = bmodel.get_participant_info(registration_number)
    itoken = None
    issued_token = None

    if participant_info:
        issued_token = get_issued_valid_token_for_participant(
            registration_number)

    else:
        status = tStatus.INVALID_USER
        logger.warning('Participant info not found for %d',
                       registration_number)
        return status, None

    status_str = None

    if issued_token:
        itoken = issued_token
        status = tStatus.TOKEN_REISSUED
        status_str = 'OLD'

    else:
        itoken = get_next_itoken()

        if itoken:
            itoken.token_state = ccfg.TokenState.ISSUED.value
            itoken.issued_on = dt.date.today()
            itoken.issued_to = registration_number
            itoken.save()
            logger.info('%s token issued to %d', itoken.userid,
                        registration_number)
            status = tStatus.SUCCESS
            status_str = 'NEW'

        else:
            logger.critical('Participant token exhausted %d',
                            registration_number)
            status = tStatus.TOKEN_EXHAUSTED

    if itoken:
        sa.send_token(participant_info.mobile_number, status_str,
                      itoken.userid, itoken.password)

    return status, itoken