Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I've currently got a system with a user account and login system. I'm trying to implement a "lockout" function, so that after 3 incorrect password attempts, the user is locked out. Currently this only involves a popup window, and simply warns the user instead of locking them out. I'm trying to find a good way to do this, based around a timeout so after a set amount of time the user can try to access their account again.
One idea I have is to write the time of lockout to a text file, and then have the system check for the previous lockout time from this text file and allow login if enough time has elapsed, however this seems to be an inelegant way to solve this.
Is there any other ways that this could be done? thanks
Usually, you'll use a database with fields like
id
username
password
failedAttempts (int)
lastFailed (date)
lastLogin (date)
When they fail to login, you increment failedAttempts and save the time in lastFailed.
Then on login, you check if (failedAttempts < threshold) or ((now - lastFailed) > timeThreshold).
On login you reset failedAttempts = 0, and lastFailed = null
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 months ago.
Improve this question
in the application I am developing I can specify an expiration date of a license and now I want to create an a java spring boot api that can send an email to a specific email before a specific time period (the user can choose the time period). The purpose of the email is to notify the user that his license is about to end.
For example:
The user chooses an expiration date of 3/8/2023 and chooses to be notified 3 months before the expiration date chosen. An email gets sent to the user's email on 3/5/2023 notifying the user that the license is about to end.
Any help is highly appreciated.
You need to store the info in database. So that your system knows when to send the email. For ex, having two columns in a table like send_notif_date, send_to_user.
write a job(you can use Quartz for this) which will pick all details of user for which we need to send the emails based on if today equalsTo send_notif_date
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
This post was edited and submitted for review 9 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I only started coding about a month ago and I am trying to add a code or program to my work in order to make it store user input and even after rerunning the program, the input will still be kept. Confused? For example, when you make an account on Facebook, they will keep your email and password so next time you just have to login without making the account again. Something like a database to store value I am guessing?
When a program terminates, it looses all the values stored in variables.
This is because we have a GC (Garbage Collection) mechanism which helps to clear up data which are not used.
In your case, to persist data post restart, we need to store to some external store (persistent storage) rather than keeping in the memory.
Your external store can be a database or can be a simple file.
Create a file and store your values in it. Once you restart the program, read the values again from it.
You would require a storage to store the data, as rerunning will erase all previous data. Any filesystem/db can be used to resolve your issue.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I need to implement a countdown timer for a quiz in a Spring boot webApp.I tried to implement it using JS but every time the user clicks on the next question button the timer resets. the timer must be of five minutes and at 00:00 the quiz must be auto-submitted.
In past I have implemented something similar, It was for learning purpose. On server-side I have created cookie for user and session, then I have stored start time in session for this user. So refreshing website would just pick up start time from user session kept on server. As for auto-submit functionality, you would need to implement It on the frontend side. Using JS you can check whether time has reached 00:00, and run function that performs submit.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am creating a sign-in and sign-up form just for practice. When the application runs for the first time, I would like the sign-up form to show first. How can I detect that the application is running for the first time?
One thing you could do is to check for the existence of a file. If it exists, then you know the application has been run before, otherwise you know that it has not run before, and so you create it.
File file = new File("some/path/filename.txt");
boolean firstRun = false;
if(!file.exists()){
firstRun = true;
file.createNewFile();
}
if(firstRun){
// Code to run if it is the first time running the app
}else{
// Code to run if it is not the first time running the app
}
In the future, this file could potentially be used for user configuration and such.
A sign up changes the state of your application. After it, there is a signed up user. So, what you might want is to check if there is a signed user. If you check for the first start, the user might exit the program without sign up and will never be asked for sign up on subsequent starts.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Basically what I am asking is how do games check what the user inputs all the time, not just when the user is asked to input an integer or a word but I am ALL the time.
Example: Runescape, Minecraft, WoW, any game developed that uses text based communication always has that function that if you type in the pretty box it spits out what you said in a world chat box, how do I do that as such (Not a world chat box) but simply a put out.
Simply put, by polling. Games use loops which run 20+ times a second and check for whether the user is causing input via keyboard/mouse.
There are hundreds of great tutorials