Thanks. Before you replied I had tried : user = auth.get.user()[first_name]
With an error.. 'first_name' is not defined Regards On Mon, Feb 24, 2020, 02:02 Val K <valq7...@gmail.com> wrote: > `auth` in py4web is no the same as in web2py > to get user-record you should > ... > def index(): > user = auth.get_user() > > > > On Sunday, February 23, 2020 at 8:47:46 PM UTC+3, Maurice Waka wrote: >> >> >> import os >> import datetime as dt >> from datetime import datetime, timedelta, date >> from .common import db, session, T, cache, auth, logger, authenticated, >> unauthenticated >> from py4web import action, request, DAL, Field, Session, Cache, user_in, >> abort, redirect, URL, Field >> from py4web.utils.auth import Auth >> from py4web import action, request, abort, redirect, URL, Field >> from py4web.utils.form import Form, FormStyleBulma >> from py4web.utils.publisher import Publisher, ALLOW_ALL_POLICY >> from pydal.validators import IS_NOT_EMPTY, IS_INT_IN_RANGE, IS_IN_SET, >> IS_IN_DB, IS_EMAIL, IS_MATCH >> from yatl.helpers import INPUT, H1, HTML, BODY, A >> from pydal.validators import * >> >> db.define_table('answers', >> Field('author', 'reference auth_user', >> default=auth.user_id, readable=False, writable=False), >> Field('userId','reference >> auth_user',unique=True,readable=False,writable=False), >> Field('quest', 'text', requires=IS_NOT_EMPTY(),), >> auth.signature >> ) >> db.define_table('posts', >> Field('author', 'reference auth_user', >> default=auth.user_id, writable=False, readable=False), >> Field("message", 'text', requires=IS_NOT_EMPTY(), >> notnull=False), >> auth.signature >> ) >> >> @authenticated() >> def index(): >> codes = [] >> del codes[:] >> r = [] >> yesterday = dt.datetime.utcnow() - dt.timedelta(days=1) >> db(db.answers.modified_on < yesterday).delete() >> """Avoid an empty table""" >> user = db(db.posts.author== auth.user_id).select(db.posts.id, >> db.posts.author, orderby=~db.posts.id, limitby=(0,1)).first() >> if user.author if user else None == auth.user_id: >> pass >> else: >> db.posts.insert(message="Welcome "+auth_user.first_name+'.'+' >> Thank you for signing in with us. Blah blah blah.', author=auth.user_id, >> created_by=auth.user_id, modified_by=auth.user_id) >> db.commit() >> On Sunday, February 23, 2020 at 8:28:28 PM UTC+3, Val K wrote: >>> >>> Show your code, please >> >> -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to web2py+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/web2py/19c4dd56-ffc3-40bb-9067-e5525ffafcf7%40googlegroups.com > <https://groups.google.com/d/msgid/web2py/19c4dd56-ffc3-40bb-9067-e5525ffafcf7%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/CAAcHJF-wyMTHVVL66rLWYKYiKZ_mjBCh88WhRtUnC_38rJ0Cug%40mail.gmail.com.