<commit_before>abstract class BaseController {
    def auth = {
        if (!session.userId) {

            if (params.controller == "hut" && (params.action == "show" || params.action == "showpic")) {
                Hut hut = Hut.get(params.id)

                if (!hut.openHut) {
                    redirect(controller: 'hut', action: 'denied')

                    return false
                }
            } else {
                def originalRequestParams = [controller: controllerName, action: actionName]

                originalRequestParams.putAll(params)

                session.originalRequestParams = originalRequestParams

                redirect(controller: 'person', action: 'login')

                return false
            }
        } else {
            if (params.controller) {
                switch (params.controller) {
                    case "person":
                        Person p = Person.findByUserId(session.userId)

                        if (params.id) {
                            Person p2 = Person.get(params.id)

                            if (!p.admin) {

                                if (p.id != p2.id) {
                                    redirect(controller: 'person', action: 'denied')

                                    return false
                                }
                            }
                        }
                        break;
                    case "hut":
                        if (params.action == "edit" || params.action == "delete") {

                            Person p = Person.findByUserId(session.userId)

                            Hut hut = Hut.get(params.id)

                            if (!(p.admin || (p == hut.owner))) {
                                redirect(controller: 'hut', action: 'denied')

                                return false
                            }
                        }

                        if (params.action == "show" || params.action == "showpic") {

                            Person p = Person.findByUserId(session.userId)

                            Hut hut = Hut.get(params.id)

                            if (!(p.admin || (p == hut.owner) || hut.users.users.contains(p))) {
                                redirect(controller: 'hut', action: 'denied')

                                return false
                            }
                        }
                        break;
<commit_msg>[svn] o Fixes #63. Don't check permissions if hut is open.<commit_after>abstract class BaseController {
    def auth = {
        if (!session.userId) {

            if (params.controller == "hut" && (params.action == "show" || params.action == "showpic")) {
                Hut hut = Hut.get(params.id)

                if (!hut.openHut) {
                    redirect(controller: 'hut', action: 'denied')

                    return false
                }
            } else {
                def originalRequestParams = [controller: controllerName, action: actionName]

                originalRequestParams.putAll(params)

                session.originalRequestParams = originalRequestParams

                redirect(controller: 'person', action: 'login')

                return false
            }
        } else {
            if (params.controller) {
                switch (params.controller) {
                    case "person":
                        Person p = Person.findByUserId(session.userId)

                        if (params.id) {
                            Person p2 = Person.get(params.id)

                            if (!p.admin) {

                                if (p.id != p2.id) {
                                    redirect(controller: 'person', action: 'denied')

                                    return false
                                }
                            }
                        }
                        break;
                    case "hut":
                        if (params.action == "edit" || params.action == "delete") {

                            Person p = Person.findByUserId(session.userId)

                            Hut hut = Hut.get(params.id)

                            if (!(p.admin || (p == hut.owner))) {
                                redirect(controller: 'hut', action: 'denied')

                                return false
                            }
                        }

                        if (params.action == "show" || params.action == "showpic") {

                            Person p = Person.findByUserId(session.userId)

                            Hut hut = Hut.get(params.id)

                            if (!(hut.openHut || p.admin || (p == hut.owner) || hut.users.users.contains(p))) {
                                redirect(controller: 'hut', action: 'denied')

                                return false
                            }
                        }
                        break;

{'fraction_non_alphanumeric': 0.09895203546956872, 'fraction_numerical': 0.0012091898428053204, 'mean_word_length': 0.8885083713850838, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3132906', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1079, 'n_words': 239}