I'm developing a flask application where I have implemented Azure AD based authentication. Now when user log in they can select 3 different app route based on their choice.
Inside each app route there is post method implemented on button click which start provisioning of resources such as Azure VM.
I want to start timer only when user click that button and redirect to /logout when timer ends.
Thanks in advance.
Have you tried doing it with sessions?
#app.route('your_url', methods = ["POST"])
def your_function():
session.permanent = True
app.permanent_session_lifetime = timedelta(minutes=60)
Then use some type of fetch/ajax that when you click the button at the same time a POST request to "/your_url" is triggered with an allocation of a session that would expire after 60 minutes.
Find the session you allocated and if it is not existing then proceed to logout. That's what flask-login and other flask projects seems to be doing as an approach.
Related
Django 1.11.8
I have to logout users that close the browser (or tab) without waiting the expire time session (there is one limit for number of the users online).
I can't solve with SESSION_EXPIRE_AT_BROWSER_CLOSE = True ,it doesn't delete the sesssion.
My idea is to add an inactivity timer on the server side for each user session, but I didn't find solutions or some examples about it.
Do you have suggestions how to implement this with django server?
Would be one a good idea?
I created a notification system adapted to my website and it's works. When a user is on home page, he can see his notifications.
But currently, for refresh his notifications the user have to reload the home page... (currently notifications visibles only on home page)
I want the notifications refresh automatically where there is a new notification, so without reload the page.
I want also user can be alerted by a new notification in all pages of my website (example : a div appears with notification
message).
How can I do this ?
Thank you !
PS : My Notification is very simple, so a Notification model with a Manager.
You can probably look at websockets. Check this out tornado
I dont know how you have setup your notification system, but making the use of websocket with combination of javascripting is way to go in my opinion.
Apparently when you hit the refresh button, the browser reloads the entire site (with all the scripts), resetting everything, including the "loggedInUser" I put in the application controller.... Is it the browser thing? Or ember thing?
How to stop any of them / both to just stop doing that...? Or should I take the non-trivial route of storing stuffs in browser local storage, etc? Really?
Thanks,
Raka
It's not too difficult to keep the state of your app on browser refresh. I chose to store an auth token, user id, and user role in cookies. Here is an Auth Manager object that can be used to manage the client side of user authentication.
Gist auth_manager.js
I instantiate it when the app loads, and call it's 'authenticate' method on init, and when a user successfully authenticates from the server, like in my login or sign up controllers.
I hope this points you in the right direction.
There is no any "SiteCreated" or "SiteCreating" type of event receiver in app model. But, I want to trigger some events on the site collection creation. There are some web level events in the app model but I need some sort of functionality which will execute when any site collection gets created.
Will this be possible through remote event receiver on "WebProvisioned" event??
Please share your thoughts on this.
Lalit, you can not deploy custom actions on site collection creatiion event in App model because app it just a web which is created when app is deployed on your web or site collection.
So, if you want to deploy your custom actions, do it in App Installation event.
Open properties of your app project and set "true" to "Handle App Installed" event.
Rishi is correct. Those type of events are not supported by apps.
You can use Remote Event Receiver using Apps model (hosted-provider), but I do not know you have a method to capture the event of a site crearcion...
we are working on a mobile application for a dating site, mixing native views and web views.
The user need to log in into the iPhone app.
This is done with a webservice (WS). The WS checks the username/password in the database, then creates all the session variables and finally returns the CFID/CFTOKEN to the application.
But when the application try to call a web view including the CFID/CFTOKEN in the URL, the session is not set, and the user has to log in again in the webview... When he logs in again, then the session is created and stay active as usual.
Does I understand well the use of CFID/CFTOKEN ?
How to handle the session between 2 applications?
Thanks for your time !
Thank you for your answers. As Jason said, the web views are within the iphone app and we are on ColdFusion 8 The process i need to develop is the following: 1 - the user open the app and fill in his credentials 2 - the app authenticates him with a webservice 3 - the session is created 4 - the user navigate through the application (wich is webservice-based, no problem here...) 5 - some parts (80%) of the screens of application are webviews (non-native). When the user goes to webviews, he needs to be logged in automatically.
My idea was to authenticate the user with the webservice, then returns the CFID/CFTOKEN to the app, and append it to the url of each web view. But this do not work, the user has to log in twice, once in the app, once in the webviews.