私の grails アプリでは、ユーザーがログインしているかどうかを確認するためにインターセプターを使用しています。そうでない場合、ユーザーはログイン ページ (/account/index) にリダイレクトされます。これは何らかの理由で機能しません。(追加情報: コントローラーの名前空間を定義しませんでした。)
私のアプリケーションからの関連コードスニペット:
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?(.$format)?"{
constraints {
// apply constraints here
}
}
"/"(controller: "account", action:"index")
"500"(view:'/error')
"404"(view:'/notFound')
}
}
application.yml で設定しました:
grails:
profile: web
cors:
enabled: true
codegen:
defaultPackage: myapp
gorm:
reactor:
# Whether to translate GORM events into Reactor events
# Disabled by default for performance reasons
events: false
spring:
jmx:
unique-names: true
main:
banner-mode: "off"
groovy:
template:
check-template-location: false
devtools:
restart:
additional-exclude:
- '*.gsp'
- '**/*.gsp'
- '*.gson'
- '**/*.gson'
- 'logback.groovy'
- '*.properties'
- 'grails-app/views/**'
- 'grails-app/i18n/**'
- 'grails-app/conf/**'
management:
endpoints:
enabled-by-default: false
ただし、コアを有効に設定するか、これらの行を削除しても違いはありませんでした。
インターセプターのリダイレクト (コントローラーごとに 1 つのインターセプターがありますが、それが正しい方法だと思います) は次のようになります。
class ZoneInterceptor {
boolean before() {
Boolean allowed = session?.user != null
if (!allowed) {
redirect(controller: "account", action: "index")
return false
}
return allowed
}
boolean after() { true }
void afterView() {
// no-op
}
}
このコードは私にファンキーなメッセージを与えます.ブラウザはポップアップを表示します.「xdg-openを開きますか? ウェブサイトはこのアプリケーションを開きたいと思っています. . だからこそ、問題は間違いなく私の側にあると思います)。
どうすれば解決できますか?xdg-openポップアップではなく、適切なリダイレクトが必要です。
事前にご協力いただきありがとうございます。