Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7606709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:28:39+00:00 2026-05-31T00:28:39+00:00

I am a beginner in Grails 2.0 framework and I am trying to follow

  • 0

I am a beginner in Grails 2.0 framework and I am trying to follow this tutorial http://grails.org/Simple+Avatar+Uploader . I implemented this code but I am getting an error in UserController.groovy at this line ‘def user = User.current(session)’ as ‘ No such property: User for class: grailtwitter.PersonController’ I assume that this line takes the user’s current session. I am looking for an explanation of how this works ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:28:40+00:00Added an answer on May 31, 2026 at 12:28 am

    This code is incomplete. The controller presupposes that you have a way of identifying the currently logged in user. Implicitly the line def user = User.current(session) assumes that you have defined a current() method on the user class itself that takes in a session and presumably uses some field that you’ve set in it to retrieve a User. That would be kind of dumb.

    A common way to do this would be to build your own authentication mechanism. Note that this is a naive practice and you are far better off using Spring Security Core unless you want to leave your application open for gaping security holes. But, for practice, something like:

    def login = {
        //if you're stupid enough to store your passwords in plain text and not sanitize user inputs, you deserve to be hacked
        def user = User.findByPassword(params.password) 
        if(user){
           session.user = user
        }
    }
    

    You could then replace the offending line in the tutorial (–def user = User.current(session)–) with

    def user = session.user ?: new User(userid:"I'm a little teapot") 
    

    Before you go much further, you probably want to walk through this free eBook on Grails before you get much further. Also highly recommend Grails in Action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

PHP beginner working from a tutorial. I'm trying to do a simple upload from
A beginner's question, probably a trivial one. Here's the XUL code snippet: <window xmlns=http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul>
Beginner at Django here, I've been trying to fix this for a long time
Beginner here See - http://www.w3schools.com/js/tryit.asp?filename=try_dom_tablerow_cells In this example, when change content is pressed, new
A beginner question: I don't know how best to structure this bit of code,
I'm a beginner in jQuery area and I have simple question like this :
I'm a beginner of Grail. I learned from the quick-start tutorial that the grails
Beginner in Android development. My code crashes. I have made a simple Java method
I'm a beginner in Grails development. I want to make a new simple MySQL
beginner PHP programmer here trying to use the mailchimp API... I keep getting this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.