コード例 #1
0
ファイル: index.py プロジェクト: hwaring/python-zoom
    def POST(self, USERNAME, PASSWORD, LOGIN_BUTTON="", url=""):

        if LOGIN_BUTTON:
            if user_exists(USERNAME):

                if potential_attack(USERNAME):
                    deactivate_user(USERNAME)
                    logger.security("user account deactivated")

                elif user.login(USERNAME, PASSWORD):
                    username = user.username
                    user_id = user.id
                    msg = '<a href="/users/%(user_id)s">%(username)s</a> logged in' % locals()
                    logger.info("user %s successfully logged in" % USERNAME)
                    logger.activity("session", msg)
                    return redirect_to("/")
            else:
                logger.security("unknown username (%s)" % USERNAME)

            logger.security("failed login attempt", USERNAME)
            error("invalid username or password")

        else:
            # API call
            if user.login(USERNAME, PASSWORD):
                return "OK"
            else:
                return "FAIL"
コード例 #2
0
ファイル: test_user.py プロジェクト: brettgoss/datazoomer
 def test_user_is_activate(self):
     user = OldUser('user1')
     self.assertEqual(user.status, 'A')
     deactivate_user(user.username)
     user = OldUser('user1')
     self.assertEqual(user.status, 'I')
     activate_user(user.username)
     user = OldUser('user1')
     self.assertEqual(user.status, 'A')
コード例 #3
0
    def login_button(self):

        if login_form.validate(data):

            values = login_form.evaluate()

            username = values['USERNAME']
            password = values['PASSWORD']
            remember_me = values['REMEMBER_ME']

            as_api = os.environ.get('HTTP_ACCEPT','') == 'application/json'

            if user_exists(username):
                if potential_attack(username):
                    deactivate_user(username)
                    logger.security('user account (%s) deactivated' % username)
                elif user.login(username, password, remember_me):
                    if as_api:
                        logger.info('user %s successfully logged in via api' % username)
                        return '{}'
                    else:
                        username = user.username
                        user_id = user.id
                        msg = '<a href="/users/%(user_id)s">%(username)s</a> logged in' % locals()
                        logger.activity('session', msg)
                        logger.info('user %s successfully logged in' % username)

                        referrer = data.get('referrer')
                        if referrer:
                            return redirect_to(referrer)
                        return redirect_to('/'+user.default_app)
            else:
                logger.security('unknown username (%s)' % username)
            logger.security('failed login attempt', username)

            if as_api:
                return '{"message": "invalid username or password"}'
            else:
                error('invalid username or password')
コード例 #4
0
ファイル: model.py プロジェクト: hwaring/python-zoom
 def deactivate(self):
     return deactivate_user(self.username)
コード例 #5
0
ファイル: model.py プロジェクト: brettgoss/datazoomer
 def deactivate(self):
     audit('deactivate user account', self.username, '')
     return deactivate_user(self.username)
コード例 #6
0
ファイル: model.py プロジェクト: dsilabs/datazoomer
 def deactivate(self):
     audit('deactivate user account', self.username, '')
     return deactivate_user(self.username)