Exemplo n.º 1
0
    def post(self):
        request = self.request
        _ = request.translate

        model_state = request.model_state
        model_state.schema = LoginSchema()

        if not model_state.validate():
            return self._get_edit_info()

        LoginName = model_state.value('LoginName')
        user = request.dbsession.query(models.Users).filter_by(UserName=LoginName).first()
        if not user:
            model_state.add_error_for('*', _('Invalid User Name or Password'))
            return self._get_edit_info()

        hash = Crypt(user.PasswordHashSalt, model_state.value('LoginPwd'), user.PasswordHashRepeat)
        if hash != user.PasswordHash:
            model_state.add_error_for('*', _('Invalid User Name or Password'))
            return self._get_edit_info()

        headers = remember(request, user.UserName)
        start_ln = [x.Culture for x in _culture_list if x.LangID == user.LangID and x.Active]
        if not start_ln:
            start_ln = [default_culture()]

        return HTTPFound(location=model_state.value('came_from', request.route_url('search', ln=start_ln[0])),
                         headers=headers)
Exemplo n.º 2
0
 def default_culture(self):
     return default_culture()