I would suggest you to use the new way of customizing auth tables :

"""

The simplest way is to add extra fields:

## after auth = Auth(db)
auth.settings.extra_fields['auth_user']= [
  Field('address'),
  Field('city'),
  Field('zip'),
  Field('phone')]
## before auth.define_tables(username=True)

"""
http://web2py.com/books/default/chapter/29/09/access-control#Customizing-Auth


On Thu, Dec 13, 2018 at 4:19 PM Ben Duncan <linux...@gmail.com> wrote:

> Ok, I THINK the error is due to our custome tables
> ie: Group is defined as :
>
> db.define_table('auth_group',
>     Field('group_id', type='integer'),
>     Field('role', type='string', length=50),
>     Field('description', type='string', length=256),
>     Field('company_number', type='integer', default=0),
>     Field('created_on', type='datetime'),
>     Field('created_by', type='string', length=50),
>     Field('modified_on', type='datetime'),
>     Field('modified_by', type='string', length=50),
>     Field('notes', type='text'),
>     primarykey=['group_id'],
>     migrate=False)
>
> SO (Correct me if I am wrong) it's trying to use the "self.user.id" which
> is not defined, since these are cutome tables.
>
> If so, how to I go about correcting this ?
>
> As always, thanks ...
>
> *Ben Duncan*
> DBA / Chief Software Architect
> Mississippi State Supreme Court
> Electronic Filing Division
>
>
> On Thu, Dec 13, 2018 at 3:06 PM Ben Duncan <linux...@gmail.com> wrote:
>
>>
>> *Ben Duncan*
>> DBA / Chief Software Architect
>> Mississippi State Supreme Court
>> Electronic Filing Division
>> Argg ... spoke to soon :
>>
>> Errors :
>>
>> web2py™ Version 2.17.2-stable+timestamp.2018.10.06.18.54.02
>> Python Python 2.7.13: /usr/bin/python (prefix: /opt/rh/python27/root/usr)
>> Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>> 17.
>> 18.
>>
>> Traceback (most recent call last):
>>   File "/data/web2py/web2py/gluon/restricted.py", line 219, in restricted
>>     exec(ccode, environment)
>>   File "/data/web2py/web2py/applications/Mec/controllers/default.py" 
>> <https://10.13.70.47/admin/default/edit/Mec/controllers/default.py>, line 
>> 205, in <module>
>>   File "/data/web2py/web2py/gluon/globals.py", line 421, in <lambda>
>>     self._caller = lambda f: f()
>>   File "/data/web2py/web2py/applications/Mec/controllers/default.py" 
>> <https://10.13.70.47/admin/default/edit/Mec/controllers/default.py>, line 
>> 25, in user_bare
>>     user = auth.login_bare(username, cryptpassword)
>>   File "/data/web2py/web2py/gluon/tools.py", line 2283, in login_bare
>>     self.login_user(user)
>>   File "/data/web2py/web2py/gluon/authapi.py", line 739, in login_user
>>     self.update_groups()
>>   File "/data/web2py/web2py/gluon/authapi.py", line 503, in update_groups
>>     table_membership.user_id == self.user.id).select()
>>   File 
>> "/opt/rh/python27/root/usr/lib/python2.7/site-packages/pyDAL-17.11-py2.7.egg/pydal/objects.py",
>>  line 109, in __getattr__
>>     raise AttributeError
>> AttributeError
>>
>> Error snapshot [image: help]
>> <https://10.13.70.47/admin/default/ticket/Mec/10.13.69.144.2018-12-13.15-04-19.fd6eaf1e-d535-4d77-a405-c1054cbd0199#>
>>
>> <type 'exceptions.AttributeError'>()
>>
>> inspect attributes
>> Frames
>>
>>    -
>>
>>    *File /data/web2py/web2py/gluon/restricted.py in restricted at line
>>    219* code arguments variables
>>    -
>>
>>    *File /data/web2py/web2py/applications/Mec/controllers/default.py in
>>    <module> at line 205* code arguments variables
>>    -
>>
>>    *File /data/web2py/web2py/gluon/globals.py in <lambda> at line 421*
>>    code arguments variables
>>    -
>>
>>    *File /data/web2py/web2py/applications/Mec/controllers/default.py in
>>    user_bare at line 25* code arguments variables
>>    -
>>
>>    *File /data/web2py/web2py/gluon/tools.py in login_bare at line 2283*
>>    code arguments variables
>>    -
>>
>>    *File /data/web2py/web2py/gluon/authapi.py in login_user at line 739*
>>    code arguments variables
>>    -
>>
>>    *File /data/web2py/web2py/gluon/authapi.py in update_groups at line
>>    503* code arguments variables
>>    -
>>
>>    *File
>>    
>> /opt/rh/python27/root/usr/lib/python2.7/site-packages/pyDAL-17.11-py2.7.egg/pydal/objects.py
>>    in __getattr__ at line 109* code arguments variables
>>    Function argument list
>>
>>    (self=<Row {'ap_allowed': False, 'iv_allowed': False, ...ress_2':
>>    None, 'address_3': None, 'notes': None}>, k='id')
>>    Code listing
>>
>>    104.
>>    105.
>>    106.
>>    107.
>>    108.
>>    109.
>>    110.
>>    111.
>>    112.
>>    113.
>>
>>
>>        def __getattr__(self, k):
>>            try:
>>                return self.__getitem__(k)
>>            except KeyError:
>>                raise AttributeError
>>
>>        def __copy__(self):
>>            return Row(self)
>>
>>    Variables
>>    builtinAttributeError <type 'exceptions.AttributeError'>
>>
>> Context
>>
>> locals request session response
>> In file: /data/web2py/web2py/applications/Mec/controllers/default.py
>>
>> 1.
>>
>> <code object <module> at 0x7f1259ef06b0, file 
>> "/data/web2py/web2py/applications/Mec/controllers/default.py", line 11>
>>
>>
>> On Thu, Dec 13, 2018 at 3:02 PM Ben Duncan <linux...@gmail.com> wrote:
>>
>>> Ok, I seem to have it working now:
>>>
>>> My Code Snippets if anyone is interested:
>>>
>>> controllers/default.py
>>> def user_bare():
>>>     alg = 'pbkdf2(1000,20,sha512)'
>>>     custom_auth_table.password.requires = None
>>>     username, password = request.post_vars['username'],
>>> request.post_vars['password']
>>>     session.is_logged_in = "NO"
>>>     cryptpassword =
>>> str(CRYPT(digest_alg=alg,salt='Mars_Salt_4u')(password)[0])
>>>
>>>     user = auth.login_bare(username, cryptpassword)
>>>
>>>     #if auth.is_logged_in() :
>>>     if user :
>>>        session.is_logged_in = "YES"
>>>        if auth.user['company_number'] == 0:
>>>          redirect(URL('company_choose'))
>>>        else:
>>>          redirect(URL('index'))
>>>
>>>     return dict()
>>>
>>>
>>> view/default/user_bar.html
>>>
>>> {{extend 'layout.html'}}
>>>
>>> <INPUT type="button" value="HOME"
>>> onclick="location.href='{{=URL('index')}}'"/>
>>>
>>> <form enctype="multipart/form-data"
>>>   action="{{=URL()}}" method="post"> <!--{{#or use
>>> =form.custom.begin}}-->
>>>      <div class="form-group">
>>>           <input type="text" class="form-control" name="username">
>>>      </div>
>>>      <div class="form-group">
>>>           <input type="password" class="form-control" name="password">
>>>      </div>
>>>      <button type="submit">
>>>            Submit
>>>      </button>
>>> </form> <!--{{#or use =form.custom.end}}-->
>>>
>>>
>>>
>>> *Ben Duncan*
>>> DBA / Chief Software Architect
>>> Mississippi State Supreme Court
>>> Electronic Filing Division
>>>
>>>
>>> On Thu, Dec 13, 2018 at 2:57 PM Ben Duncan <linux...@gmail.com> wrote:
>>>
>>>> Ok, thanks, will revisit it. I was getting insert errors from it
>>>> before. Maybe my ignorance ...
>>>>
>>>>
>>>> *Ben Duncan*
>>>> DBA / Chief Software Architect
>>>> Mississippi State Supreme Court
>>>> Electronic Filing Division
>>>>
>>>>
>>>> On Thu, Dec 13, 2018 at 2:14 PM Anthony <abasta...@gmail.com> wrote:
>>>>
>>>>> Got it, but I don't see login_bare/login_user/update_groups getting in
>>>>> the way of any of that. The update_groups method simply adds a dictionary
>>>>> of the user's current group ids/roles to the session, which can be used
>>>>> instead of doing a database lookup on each request. You are free to ignore
>>>>> it.
>>>>>
>>>>> Anthony
>>>>>
>>>>> On Thursday, December 13, 2018 at 11:34:05 AM UTC-5, Ben Duncan wrote:
>>>>>>
>>>>>> Thanks Anthony.
>>>>>>
>>>>>> I'm trying to maintain some reference to the auth mechanism , but our
>>>>>> needs get a little more convoluted.
>>>>>>
>>>>>> Some Background Info:
>>>>>> This is a accounting system (AR/AP/GL/IV/OE/PR/BI/BR/RMA/ ..etc)
>>>>>> based upon about 30 years of collected source
>>>>>> I have for Chancery / Circuit Clerks for Fees, Fines and restitution
>>>>>> and land records et.all.
>>>>>>
>>>>>> I'm trying to keep it generic as possible for the Supreme Court.
>>>>>>
>>>>>> From the Clerks view, the are elected officials for a particular
>>>>>> County/Jurisdiction. However, in some instances the may cover several
>>>>>> counties / courts (if those are small).
>>>>>>
>>>>>> Courts are grouped in "districts" and we are going to using "company
>>>>>> id" numbers to signify those courts within the districts and all courts
>>>>>> under one
>>>>>> umbrella for the database.
>>>>>>
>>>>>> Now the CLERKS have deputy clerks, who may OR may not be assigned to
>>>>>> multiple county/courts and may be limited to WHAT or what they cannot
>>>>>> do, but are designated by the "company" code to which court they will
>>>>>> have access to.
>>>>>> Add to that, the wants of our Office of the State Auditors our very
>>>>>> own AOC (Administrator of Courts and their auditors) it gets pretty
>>>>>> convulsed in a hurry.
>>>>>>
>>>>>> Now looking at the ACCESS CONTROL stuff, we are really a flipped
>>>>>> version of that - GROUP and MEMBERSHIP before and controlling the
>>>>>> auth_user.as well as company id in the group and
>>>>>> membership/permission file.signifying what court the have jurisdiction to
>>>>>> use. (Phew).
>>>>>>
>>>>>> I hope I haven't totally confused you.
>>>>>>
>>>>>> Thanks again ...
>>>>>> *Ben Duncan*
>>>>>> DBA / Chief Software Architect
>>>>>> Mississippi State Supreme Court
>>>>>> Electronic Filing Division
>>>>>>
>>>>>>
>>>>>> On Thu, Dec 13, 2018 at 10:03 AM Anthony wrote:
>>>>>>
>>>>>>> On Wednesday, December 12, 2018 at 6:57:07 PM UTC-5, Ben Duncan
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Yes, I wanted to just use the auth_table.
>>>>>>>> Everything else is controlled outside of the normal mechs ..
>>>>>>>>
>>>>>>>
>>>>>>> If you don't want to use the Auth login mechanism, then I suppose
>>>>>>> you can write your own logic. Keep in mind you will then be responsible 
>>>>>>> for
>>>>>>> updating the session with the appropriate auth data so Auth knows the 
>>>>>>> user
>>>>>>> is logged in on each subsequent request. But really, I don't see why you
>>>>>>> would do that just to avoid having the list of group memberships
>>>>>>> automatically updated upon login -- what problem is that creating for 
>>>>>>> you?
>>>>>>>
>>>>>>> Anthony
>>>>>>>
>>>>>>> --
>>>>>>> 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.
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>> --
>>>>> 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.
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>> --
> 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.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to