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 8153943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:10:54+00:00 2026-06-06T16:10:54+00:00

i have an application where we allow users to use Oauth2 for authentication and

  • 0

i have an application where we allow users to use Oauth2 for authentication and even Custom User Registrations. All the Users are saved into the default User entity in the datastore. If the user is logging in using Oauth2 for the first time a new record in the default User entity is created like this:

  """Check if user is already logged in"""
  if self.logged_in:
    logging.info('User Already Logged In. Updating User Login Information')
    u = self.current_user
    u.auth_ids.append(auth_id)
    u.populate(**self._to_user_model_attrs(data, self.USER_ATTRS[provider]))
    u.put()
  else:
    """Create a New User"""
    logging.info('Creating a New User')
    ok, user = self.auth.store.user_model.create_user(auth_id, **self._to_user_model_attrs(data, self.USER_ATTRS[provider]))

    if ok: 
      self.auth.set_session(
        self.auth.store.user_to_dict(user)
      )   
self.redirect(continue_url)

for custom registrations records are inserted through the following handler.

class RegistrationHandler(TemplateHandler, SimpleAuthHandler):

  def get(self):
    self.render('register.html')

  def post(self):
    """Process registration form."""
    user = 'appname:%s' % self.request.get('email')
    name = '%s %s' % (self.request.get('first_name'), self.request.get('last_name'))
    password = self.request.get('password')
    avatar = self.request.get('avatar')
    act_url = user_activation.Activate(self.request.get('first_name'), self.request.get('email'))
    ok, user = User.create_user(auth_id=user, name=name, password_raw=password, email=self.request.get('email'))
    if ok: 
      self.auth.set_session(self.auth.store.user_to_dict(user))
      acc = models.Account(display_name=self.request.get('first_name'), act_url=act_url, act_key=act_url.split('activate/')[1], user=users.User(User.get_by_auth_id(self.current_user.auth_ids[0]).email))
      acc.put()
      if avatar:
        avt = models.Picture(is_avatar=True, is_approved=True, image=avatar, user=users.User(User.get_by_auth_id(self.current_user.auth_ids[0]).email))
        avt.put()
    self.redirect('/')

Now we are using webapp2_extras.sessions for session handling. We have different models like, Comments, Images, Reviews etc in which we want to use db.UserProperty() as the author field. However, the author field shows blank or None whenever we enter a record into any of these models using ‘users.get_current_user()’. I think this is because we are handling the sessions through webapp2 sessions.

What we want to achieve is to be able to use the db.UserProperty field in various models and link appropriately to the current user using webapp2 sessions ?

the UserProperty() has to be passed with a User Object in order for it to properly insert the records. Even though we are able to enter the records using the following code :

user = users.User(User.get_by_auth_id(self.current_user.auth_ids[0]).email)

or

user = users.User(User.get_by_auth_id(self.current_user.auth_ids[0]).name)

but then we are not able to get the whole user object by referencing to model.author

Any ideas how we should achieve this ?

  • 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-06-06T16:10:56+00:00Added an answer on June 6, 2026 at 4:10 pm

    Instead of using UserProperty to store references to the webapp2 user objects, you should instead store the auth_id as a StringProperty and add a convenience method for fetching the corresponding webapp2 user entity.

    Something like this

    from webapp2_extras.appengine.auth.models import User
    
    class Comment(db.model):
      text = db.StringProperty()
      author = db.StringProperty()
    
      def get_author(self):
        return User.get_by_auth_id(self.author)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have configured Reporting Services to allow users to use Report Builder application. Users
I have created a custom claims provider to allow users to sign into SharePoint
I have an application that allow users to choose picture from native gallery then
I have an application where I allow users to upload files, mainly PDF and
I have a ASP.NET 3.5 web application and I would like to allow users
I have a Symfony 1.4 application to allow users to enter data to a
I have .NET application and would like to allow users to write macros. Any
I have a web application that registered users use. These users have good email
We have an application which we need to allow users from our customer's systems
I have a Java Applet application. The use case is as follows: The users

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.