Open a site, log in and get data with App - ionic2

I'm making an app and I need to know if this I'm trying to do is possible. I need to open a link from a website, which will open a login screen, and then get the data from the site that opens, with HTTP.get.
First Page
I have the login and the password, but I need a function that automatically fills the fields and enter, to enter the next page, without showing to the user of preference.
The next page I can get the data with HTTP.get

Related

Oracle-Apex: Dynamically redirecting from login button

The scenario
I have implemented social authentication similarly to described by Dimitri Gielisin hist post "Facebook, Google and Custom Authentication in the same Oracle APEX 18.1 app" (http://dgielis.blogspot.com/2018/06/facebook-google-and-custom.html)
The pertinent point is that there is a button which has the request 'APEX_AUTHENICATION=FACEBOOK' which logs the user in and also hard codes the page that the user is taken to.
It works great. (However if I have a login menu item which directs back to the same page - the user name isn't updated on the page.)
The Issue
Default behaviour is for apex to redirect users to the login page when they attempt to access a page which is not publicly available.  After logging in the user is taken to the page hard coded page in the button (except for modal dialogues which just produce an invalid session error). 
I'd love it if they could sign in and then continue to the page they need to go to. Is there some not extremely cumbersome ways of doing that? I thought of trying to saving the page number I want the user to go to into an application item and then having the button redirecting based on the application item- but while I was saving the page number the dynamic redirect in the button is not working...and I feel like I'm fighting the apex framework...
Is there a better way? If not can a button reference an item for the page number? I was trying &APP_ITEM. but that didn't seem to work...
(I"m using Apex 20.1)

Django ERR_CACHE_MISS on login page after clicking a link and back

I have a login page with a form with username and password fields and a submit button. In the same page there are links to other pages on the site.
I'm using the vanilla Django login view. The user can login using the correct credentials, otherwise the login form shows authentication error as expected. Everything works fine so far. The issue I'm having is reproducible this way:
go to login page and input wrong credentials, submit
correctly validation errors appear on the form
click some link on the page
correctly the browser brings me on the other page following the GET request
click on browser go back button
Or, another way:
go to login page and input wrong credentials, submit
correctly validation errors appear on the form
click on browser go back button
click on browser go forward button
At this point I get this message from the browser:
Confirm Form Resubmission
This webpage requires data that you entered earlier in order to be properly displayed. You can send this data again, but by doing so you will repeat any action this page previously performed.
Press the reload button to resubmit the data needed to load the page.
ERR_CACHE_MISS
It's weird, but even more weird is that if I check on Disable cache in Chrome DevTools Network panel, the problem disappears (ie. when I click back, I see the form precompiled with previously inserted data). So I tried to add the never_cache decorator to LoginView just to see, but then realized this view (obviously) already has the decorator applied.
I wonder what the problem is and how to solve it.

Opencart - The register user page just reloads when we click continue

I am facing an issue with my open cart website wherein the user registration page when I hit the continue button by not entering some required fields the page just reloads without showing the validation message.
The user registration is working fine, the problem happening is when I don't enter any required field like first name or email or forget to check the agreement terms, the page just refreshes without showing the required field validation message or any error when the continue is clicked.
Link: https://www.pickupbest.com/index.php?route=account/register
Varun
If you don't see the validation message after reload - open page code view (Ctrl+U in Chrome and Firefox). There you will find your error messages:
<div class="text-danger">First Name must be between 1 and 32 characters!</div>
I can see them for a split second in the browser, but then some JS removing it. It may be in the current template.
in register.tpl look for
$(element).parent().find('.text-danger').remove();
Try to comment it and see whats happens.
Or it could be catalog/view/javascript/productenquiry/productenquiry.js, this line
$('.alert, .text-danger').remove();
Try to comment it, clear cache of your browser (Ctrl+F5, reload page with cache cleaning).

How to post form then if back button pressed, redirect to another page?

What I want to achieve is, after saving data to DB with a form, I don't want the user to be able to go back on the previous page to the form again. Instead when the user presses the back button after posting the form, he/she should be redirected one page before.
For example this can the flow:
User is in admin page -> goes to add blog page -> fills the forms and saves the data to DB, then is redirected to another page (say main page).
Now when he/she presses the back button, it will be redirected to the form with already filled data in the input fields (which I don't want to).
How can I make it that after posting and being redirected, when he presses the back button, he/she will be redirected to admin page instead.
Thank you beforehand.

How to restrict users from going back to the previous page with the browser "back button" (redirect to a different page, instead)?

I am working on a site that would allow users to post some data. To successfully add a new post, the users need to go through three states: Form -> Preview -> Posted page. I want to restrict the users from going back to the Preview page with the browser "back button" once they have already reached the Posted page (instead, they should be redirected to the empty Form page). How can I implement this behaviour in Django?
I am not sure how you get this desired behavior from Django as you have limited control over the user's browser. However, in Javascript you can use:
window.location.replace(url);
which will remove history, thus preventing the back button from working.
See this stack overflow question about window location:
What's the difference between window.location= and window.location.replace()?
An idea: from your preview page, use AJAX to submit and if all is successful, window.location.replace to your posted page.
I can't speak for how to deal with this using browser technologies but with django you could just set a flag in the session.
# posted_page view
request.session['posted_page_visited'] = True
# preview_page view
if request.session.get('posted_page_visited'):
del request.session['posted_page_visited']
return http.HttpResponseRedirect("form_page")
Using js (window.location.replace(url)) doesn't fulfill this requirement because "replace url" will just replace the page with another one,Ex: if form flow goes from page1 to page2 then page3 then page4 and (window.location.replace(url)) is used in page2 (window.location.replace(page4);) then page3 will never be visited!! moreover user will still be able to go back in the same forward path meaning from page4 to page2...etc
the good thing, you can solve it by using Django session as shown below assuming users will be able to go back and forth as long as form not yet saved, and once its saved they can't go back anymore:
in page1/view function where first part of form is issued create session varaible:
in view1.py
def view1(request)
.
.
.
request.session['forward'] = True
return redirect(....)
in view2.py:
def view2(request):
if not request.session['forward']:
return redirect(..Select whatever page you want to redirect users to it..)
the same in rest of pages views..
in the last page/view where after saving the form, reset the variable:
request.session['forward'] = False
return redirect(..Select whatever page you want to redirect users to it..)
hopes its clear enough
django's form wizard should do what you want:
How it works
Here’s the basic workflow for how a user would use a wizard:
The user visits the first page of the wizard, fills in the form and submits it.
The server validates the data. If it’s invalid, the form is displayed again, with error messages. If it’s valid, the server saves
the current state of the wizard in the backend and redirects to the
next step.
Step 1 and 2 repeat, for every subsequent form in the wizard.
Once the user has submitted all the forms and all the data has been validated, the wizard processes the data – saving it to the
database, sending an email, or whatever the application needs to do.