title: Grails security implementation
body: <p>I made the following Controller.
  I can login and logout, but how can I force the the user to log in first?
  I need to start a session on login and terminate it on logout. </p>
  
  <pre><code>class UserController {
     def scaffold = User
     def login = {}
     def authenticate = {
        def user = User.findByLoginAndPassword(params.login, params.password)
        if(user){
           session.user = user
           flash.message = "Hello ${user.name}!"
           redirect(controller:"entry", action:"list")      
        } else {
           flash.message = "Sorry, ${params.login}. Please try again."
           redirect(action:"login")
        }
     }
  
     def logout = {
        flash.message = "Goodbye ${session.user.name}"
        session.user = null
        redirect(controller:"entry", action:"list")      
     }  
  }
  </code></pre>