0

Grails を使用して単純な (個人用) Web サイトをホストしようとしていますが、コントローラーがドメイン オブジェクトの追加ボタンと編集ボタンを表示しないようにする (またはパスワードで保護する) 方法を探していました。

私のコントローラーは次のようになります。

class DownloadsController {
    static scaffold = Download
}

私のドメインクラスは次のようになります。

class Download {

    static mapping = {
    }

    static constraints = {
        link(url: true)
    }

    String name
    String link

}

何か案は?

4

2 に答える 2

1

Spring セキュリティ プラグインを使用している場合は、コントローラでeditand add(および URL) のURL を保護できます。http://grails-plugins.github.io/grails-spring-security-core/docs/manual/guide/5%20Configuring%20Request%20Mappings%20to%20Secure%20URLs.htmlPOSTを参照してください。

Spring Security を使用していない場合は、要件に適していると思われるため、検討することをお勧めします。ビューで使用できる便利なタグもあります ( http://grails-plugins.github.io/grails-spring-security-core/docs/manual/guide/6%20Helper%20Classes.htmlを参照) 。

于 2013-04-08T05:45:09.857 に答える
0

手早く汚れた解決策として、次のように、コントローラーで編集/足場アクションの追加をオーバーライドできます。

class DownloadsController {
   static scaffold = Download

   //override scaffolded edit
   def edit() {
      redirect(action: "list")
   }

   //override scaffolded add
   def add() {
      redirect(action: "list")
   }
}

より洗練されたソリューションが必要な場合は、Spring Security Core プラグインをご覧ください。

于 2013-04-08T05:14:35.710 に答える