def handleLogin = {
def hashPassd = DU.md5Hex(params.password)
// Find the username
def user = User.findByUserNameAndPassword(params.userName, hashPassd)
if (!user) {
flash.message = "User not found for userName: ${params.userName}"
redirect(action:'index')
return
} else {
session.user = user
redirect(controller:'todo')
}
}
how come the if condition requires the return statement? and the else block don’t require it?
In this case the return is not necessary. If the return isn’t there it will continue to after the if, which is the end of the method, and thus returns.