Hi Jim,
This works like a charm. Thank you for this. It is what I expected
and wanted to achieve with Auth. I'll check my new project for what I may
be doing wrong, for now it seems that the scaffolding admin interface I
want to use for my app is the one that is the culprit. It has lots of
custom js and css files. I would need to figure out a way to merge them
with it properly. Again, Thank you! for your patience and wonderful
support. And thank you everyone.
Regards,
Rahul.
On Sunday, October 28, 2018 at 6:33:25 AM UTC+5:30, Jim S wrote:
>
> Rahul
>
> Let's try this a different way.
>
> Attached is a simple multi-tenant app with one table.
>
> Does this do what you need?
>
> 1. Create a new project in web2py
> 2. Replace db.py in your models dir with this one
> 3. Replace default.py in your controllers dir with this one
> 4. Replace index.html in views/default with this one
> 5. Add notes.html to views/default
> 6. Replace storage.sqlite in your databases dir with this one
>
> Depending on your version of web2py this should all work.
>
> I've created 2 logins
>
> elvis - password is password
> blueeyes - password is password
>
> Click on the notes link logged in as each of them and you'll see different
> notes show up based on the common filter.
>
> -Jim
>
> On Sat, Oct 27, 2018 at 12:52 PM Rahul >
> wrote:
>
>> Hi Dave and Jim,
>>Please find the files in the zipped archive. I have added
>> default.py, db.py, index.html and also layout file which I am converting to
>> use with web2py. called ace.html. I have also attached the views\login.html
>> file since I am extending this file specifically for login form as it is
>> different than layout file. Let me know. Thanks!
>>
>>
>> Regards,
>>
>> Rahul
>>
>> On Friday, October 26, 2018 at 5:11:12 PM UTC+5:30, Jim S wrote:
>>>
>>> Can you show the entire db.py, default py and index.html?
>>>
>>> Jim
>>>
>>>
>>> On Fri, Oct 26, 2018, 1:44 AM Rahul wrote:
>>>
Nope - doesnt help. I commented out all the user functions defined in
the controller and
# User functions ---
'''def login(): return dict(form=auth.login())
def register(): return dict(form=auth.register())
def retrieve_password(): return dict(form=auth.reset_password())
def logout(): return dict(form=auth.logout())
def profile(): return dict(form=auth.profile())
'''
I even decorated index - It does take me to the login screen but from
there nothing happens. It just wont log me in like it did before. Also, I
have two users in database but none work now. Again, register seems to
fail (It did work earlier) but now it doesnt. See screenshot of both
screens. Looks like I must be really doing something weird. If this wont
work by this Sunday. I may go back to my old style of coding and do it all
by myself. I've seriously lost 10 days reading and experimenting with Auth
to make it work . Not too much coded.
@auth.requires_login()
def index():
response.flash = T("Hello User")
#redirect(URL(r=request, c='default/user', f='login')) # Redirects
user to login page
return dict(message=T('Welcome to web2py!'))
Thanks,
Rahul
On Thursday, October 25, 2018 at 6:02:45 PM UTC+5:30, Jim S wrote:
>
> Having the default user() functions is all you need. I'd try
> commenting out your 'user' functions.
>
> -Jim
>
> On Wednesday, October 24, 2018 at 10:59:45 PM UTC-5, Rahul wrote:
>>
>> Yes this is in default.py. Please excuse me for my bad code as I am
>> still experimenting with Auth and not totally familiar with the
>> implementation. Is this the right way that I am doing it? or only having
>> user() function is enough ?
>>
>> Thanks, Rahul
>>
>> On Wednesday, October 24, 2018 at 9:45:21 PM UTC+5:30, Jim S wrote:
>>>
>>> I'm confused. Is this code in your controller somewhere?
>>>
>>> # User functions ---
>>> def login(): return dict(form=auth.login())
>>> def register(): return dict(form=auth.register())
>>> def retrieve_password(): return dict(form=auth.reset_password())
>>> def logout(): return dict(form=auth.logout())
>>> def profile(): return dict(form=auth.profile())
>>>
>>> You shouldn't need it. To override the default login stuff I've
>>> just modified the one in default.py.
>>>
>>> -Jim
>>>
>>>
>>>
>>> On Tuesday, October 23, 2018 at 11:26:45 PM UTC-5, Rahul wrote:
The user function remains as-is - No modifications done.
def user():
"""
exposes:
http:///[app]/default/user/login
http:///[app]/default/user/logout
http:///[app]/default/user/register
http:///[app]/default/user/profile