1
私はgrailsを使って作業しています。特定のユーザーのアカウントを削除するサービスを作成しました。ログインしたユーザーが自分のアカウントを削除することを選択すると、確認リンクが自分のメールアドレスに送信されます。そのリンクをクリックすると、そのアカウントはデータベースから削除され、同じアカウントで自動的にログアウトされますウェブサイトのホームページにリダイレクトされます。アカウントを削除することを選択したユーザーが自動ログアウトする方法は?
これは私のアカウントを削除する際のコードです。誰でも私に現在ログインしているユーザーを自動的にログアウトする方法に関するコードを教えてくれますか?多くの場合
class AccountDeletionService {
static transactional = true
def auditLogService
def springSecurityService
def delete(Registrant registrant, String key) {
if(key && registrant?.accountDeletionKey == key){
def account = springSecurityService.getCurrentUser()
def loggeduser = account.id
RegistrantEligibilityInformation.executeUpdate(
"delete RegistrantEligibilityInformation as rei where rei.registrant in (" +
"select reg from Registrant as reg where reg.account.id=:loggeduser)",[loggeduser:loggeduser])
RegistrantEducationInformation.executeUpdate(
"delete RegistrantEducationInformation as reduc where reduc.registrant in (" +
"select reg from Registrant as reg where reg.account.id=:loggeduser)",[loggeduser:loggeduser])
Registrant.executeUpdate("delete Registrant as reg where reg.account.id=:loggeduser",[loggeduser:loggeduser])
AccountRole.executeUpdate("delete AccountRole as actrole where actrole.account.id=:loggeduser)",[loggeduser:loggeduser])
Account.executeUpdate("delete Account as act where act.id=:loggeduser)",[loggeduser:loggeduser])
} else return false
}
}
どうすれば実装できますか?私はConfig.groovyファイルに任意の設定を設定する必要がありますか?または単にjavax.servlet.http.HttpSession?をインポートするだけです。 – chemilleX3
コントローラでセッションインスタンスを使用できます。 –