class SercurityFilters {
def filters = {
all(controller:'message', action:'create') {
before = {
if(!session.userid){
def wherego=request.forwardURI.replace(request.getContextPath(), '') +'?' + request.getQueryString()
session.wherego=wherego
redirect(controller:'user',action:'login')
}
}
}
def filters = {
all(controller:'message', action:'create') {
before = {
if(!session.userid){
def wherego=request.forwardURI.replace(request.getContextPath(), '') +'?' + request.getQueryString()
session.wherego=wherego
redirect(controller:'user',action:'login')
}
}
}
}
def login(){
}
def loginCheck(){
def u=User.findByNameAndPassword(params.name,params.password)
if(!u){
flash.message="用户名或密码错误,请重新输入!"
redirect(action:"login")
return
}
else{
session.userid=u.id
//render "登录成功"
redirect(uri:session.wherego)
}
}