Custom information page after registration and hide field

92 views
Skip to first unread message

brushek

unread,
Jan 30, 2021, 6:47:05 PM1/30/21
to web2py-users

Hello,

I have two problems to solve, I think they are simple, but couldn't find proper solution in docs.

I would like to show qrcode generated by qrcode module which will be used for Google Authenticator for every user after proper registration. This qrcode should be generated randomly and inserted into database. I don't wont (now) to allow edit this field by users in profile and in registration form.
I added this field this way:

#Before define tables, we add some extra field to auth_user
auth.settings.extra_fields['auth_user'] = [
    Field('motp_secret', 'password', length=512, default='', label='MOTP Secret',requires = IS_STRONG(min=16,max=16,special=0,lower=0,number=3,upper=13)),
    ]

but this way this field is seen by user  in registration form and profile editing. I would like to generate this secret and insert into database, but without possibility to edit this by user, and give him (only once) AFTER registration qrcode to scan with information, that he/she won't be allowed to login if doesn't scan qrcode and add it Google authenticator.

So questions :)
1. How to redirect after proper registration to some page on which will be custom message with qrcode ?
2. How to add silently this motp_secret field to database during registration of new user without his interaction/knowing about it

Regards
brushek


Maurice Waka

unread,
Jan 30, 2021, 9:48:08 PM1/30/21
to web...@googlegroups.com
I thought I must have seen an example of the same from github or Web2py examples.
Regards 

--
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/a22212bc-d6ef-4e97-907f-d7e2a7ff7b3dn%40googlegroups.com.

brushek

unread,
Jan 31, 2021, 8:50:13 AM1/31/21
to web2py-users
OK, Your suggestion is to search in examples of web2py and github ?

Regards

Maurice Waka

unread,
Jan 31, 2021, 12:02:41 PM1/31/21
to web2py-users

brushek

unread,
Jan 31, 2021, 6:05:09 PM1/31/21
to web2py-users
OK, thank You, but I will use this one for this purpose:


and regarding form: It was very long time I wasn't using web2py (but I have still systems working on it - very old version... :/), so I didn't go with simple solution...:

def register():

    response.view = 'register.html'
    form=auth.register()
    if form.accepts(request,session):
       response.flash="form accepted"
       redirect(URL('qrcode'))
    return dict(form=form)

def qrcode():
 response.view = 'qrcode.html'
 response.flash = 'you clicked on register'
 return dict(message="you clicked on register")

I have a question about response.view - when I comment this out, I get in browser:

invalid view (default/register.html)

why view isn't pick based on controller's function name now ?

Regards
brushek

Dave S

unread,
Feb 1, 2021, 4:50:51 AM2/1/21
to web2py-users

On Sunday, January 31, 2021 at 3:05:09 PM UTC-8 brushek wrote:
[...] 
def qrcode():
 response.view = 'qrcode.html'
 response.flash = 'you clicked on register'
 return dict(message="you clicked on register")

I have a question about response.view - when I comment this out, I get in browser:

invalid view (default/register.html)

why view isn't pick based on controller's function name now ?


What directory is your view in?  What controller is your function in?

/dps
 

brushek

unread,
Feb 2, 2021, 2:51:16 PM2/2/21
to web2py-users
hi, the function is in default.py controller in directory welcome/controllers/ and view is next to generic.html file, in welcome/views/ directory.

Regards
brushek


brushek

unread,
Feb 2, 2021, 2:54:43 PM2/2/21
to web2py-users
Thank You for Your questions. And sorry for not RTFM :). The view is working correctly, after moving it to the default welcome/views/default directory. Will try do my best to not bother You with such stupid cases...

Regards
brushek

Dave S

unread,
Feb 6, 2021, 5:32:30 AM2/6/21
to web2py-users
Most of us have our own record of missing something ... like "migration_enabled" 

/dps

Reply all
Reply to author
Forward
0 new messages