here is scaffold
view script:
$(function(){
var url = '{{=URL()}}';
function onvalidate (d) {
if d.company_list {
// do popup here using d.company_list
//finally post user choice (that is stored in the
`company` variable)
$.post(url, {'company': company}
);
}
else{
// login failed - do error-popup
};
};
function onsubmit(){
// grab 'user' and 'password' values and
send it to `url` via ajax, response will be processed by `onvalidate`
function
ajax(url, ['user', 'password'], null ,
{success: onvalidate});
return false; // this prevents the page reloading
};
// intercept form submission
$('form').submit(onsubmit);
});
controller.py:
def login():
if request.ajax:
if session.user and request.vars.company:
#validate request.vars.company
if company_is_valid:
session.company = request.vars.company
# do login using session.user
redirect(URL(...), client_side = True)
else:
#user is playing with browser console:)
return None
elif request.vars.user:
user = request.vars.user
password = request.vars.password
# do validatoin
if is_valid:
session.user = user
return response.json(dict(company_list = ...))
else:
#validation fail
return None # or somthing like response.json(dict(error =
'invalid login'))
else:
return SQLFORM.factory(...).process()
On Wednesday, February 27, 2019 at 8:29:51 PM UTC+3, Ben Duncan wrote:
>
> Ok a little more detail in pseudo code:
>
> Display Login page:
> get user name and password.
> If form validates:
> validate username and password
> if username and password validates
> popup company selection
> get company
> redirect to next page
> else
> show "username password" error message
> go back Display Login page:
> else # Forms did not pass validation ...
> go back Display Login page:
>
> That's the flow I'm used to using in CS software ...
>
> Thanks ...
>
> *Ben Duncan*
> DBA / Chief Software Architect
> Mississippi State Supreme Court
> Electronic Filing Division
>
>
> On Wed, Feb 27, 2019 at 6:53 AM Ben Duncan <[email protected]
> <javascript:>> wrote:
>
>> What I was hoping to do was a javascript popup to to choose a company,
>> then a redirect.
>> I load the company number and values in a session variables upon
>> connection.
>>
>> The user id file can have a default company (court) assignment , in which
>> case there would be no reason to do the popup, but
>> if the user had '0' in the company or was a super admin, it would do the
>> popup for company (Court)
>>
>> Make sense ?
>>
>> *Ben Duncan*
>> DBA / Chief Software Architect
>> Mississippi State Supreme Court
>> Electronic Filing Division
>>
>>
>> On Wed, Feb 27, 2019 at 2:51 AM Val K <[email protected] <javascript:>>
>> wrote:
>>
>>> Hard to understand the workflow, do you want the user to be redirected
>>> to choose the company after he has logged in? or he should make a choice
>>> along the login form filling?
>>>
>>> --
>>> 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 [email protected] <javascript:>.
>>> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.