I'm loading a webpage (for example mail.yahoo.com) in a webview. After entering username and password an AlertDialog shows asking me if I wanna remember the password which I do.
The thing is that after logging out, if another user wants to login, after he enters his own username and password, the AlertDialog asking whether to remember the password does NOT show anymore and so the old username and password are remembered.
What I want is a way to set the webview to remember the latest username and passwords that were entered. Cause (for example) if the users enters wrong username or password for the first time (after app is installed) and checks them to be remembered he wont't be able to modify the wrong entered ones and save the correct ones instead.
That is correct, the only way to do it. If you change a password you will need to reset everything with the stock app.
Try to clear user and password first in WebView Database with this code:
WebViewDatabase.getInstance(this).clearUsernamePassword();
Related
I am trying to save user phone, email, password, update password using android autofill framework.
I am using different fragments for all the above values. I tried to forcefully save values using autofillframework commit method, but that doesn't work.
I am able to save username(email) and password in two consecutive fragments and autofill popup appears for this scenario but when i try to update password its doesn't save or update the password for the same.
I want to save user details for autofill hints what should i do for the same.
So I am working on an android app where the user must login with their username and password and then Firebase will show users that are online after they have logged in. To save the user from all the frustration of logging in all the time, I implemented the remember me checkbox using SharedPreferences. This allows users automatic or fast login once they open the app without typing the username and password all over again, saving their time and frustration.
The automatic login using remember me checkbox with SharedPreferences is working fine but when the user logs in without the login screen, that is, when the remember me function kicks in, data is not sent to Firebase and users are not seen as available or online when they are actually on the app.
The first solution would be to implement a method whereby when the user logs in automatically(due to remember me), then the app communicates with Firebase and shows the user is online. This is more preferable so if anyone can please help me out with this.
The other is to save/show the previously typed username and password in the respective EditText fields so the user just has to press the login button. By this method, I believe that least coding would be required compared to the first solution. Once the user logs in from the login screen, information will be communicated to Firebase and will show the user as available/online.
Have searched a lot on how to implement the second solution, that is, to show the previously typed username and password but to no success. Searched keywords "show previously typed username edittext android studio" but got no relevant google and Youtube results.
Please help me out guys.
Finally....got the solution and I am happy with the autofill or second solution. EditText fields shows the previously entered username and password so user just has to click login. Credentials are saved only if remember me checkbox is checked.
Here is the simple code that brought my breathe back:
sharedPreferences = getSharedPreferences(myPreference, Context.MODE_PRIVATE);
if (sharedPreferences.contains(Username)) {
DriverEmail.setText(sharedPreferences.getString(Username, ""));
}
if (sharedPreferences.contains(Password)) {
DriverPassword.setText(sharedPreferences.getString(Password, ""));
}
How to find out that the user has changed the password or not via mail.
I am registering user with email
mAuth.createUserWithEmailAndPassword(id, pass);
and if user asks for forgot password
i send forgot email by
mAuth.sendPasswordResetEmail(email);
But I cannot say or figure it out that the user has changed it via email or not?
How is it possible to figure out that the password is changed or not via email?
I faced the same case few days ago when I required to save user's password in my Database too. But when user change his password via Link it was difficult for me to get user's new changed password. So I did it in the following way
While signing in through App save user's password in SharedPreferences after successful Firebase authentication. So you will always have latest user's password in your SharedPreferences. And now in your case to check user really changed his password or not, you can check if the password which is going to be saved on signin in SharedPreferences is different from the previous one, Its mean it was changed.
If you want to detect whether the user clicked the link in the password reset email, consider setting up your own handler for the email actions. Have a look at the document for inspiration, or at the default page that is used when you don't provide a custom one.
You can attach a complete listener to sendPasswordResetEmail(), and if the email has been sent, you can write in your database inside that user ID a value that will tell you that the password has been reset.
If you need to check that the user has changed the password, you can check at your database whether the user did or not.
For example, a basic structure to check that the user has changed passwords could be this
- UserID
|__ passwordReset
|_____ passwordResetPushID
|___ changed : TIMESTAMP
...
Remember that FirebaseAuth getCurrentUser() could be null at the time of changing the password if you are doing it from the login flow, but it's not going to be any problem if you do it inside your app after the user is logged in.
For the first case, you will need a little workaround, maybe storing into sharedPrefs the latest user logged in ID.
Edit
As Frank's comments, you will need a sort of function that is triggered after the user has reset the password in the browser, this solution will only let you know whenever the sendPasswordResetEmail() has been triggered but not a confirmation that the user has completed the password change, to do that, follow Frank's answer.
Think this is kind of a hard question to phrase correctly. Once the user downloads the app, i want to create a password for them to have to input a password on first time startup. When this password in input correctly, the user never has to input it again and has full access to the app from then on. Can anyone point me in the right direction of a tutorial or guide me in how this can be done? Thanks in advance!
For the easiest implementation, you can use SharedPreference. Store some value named "isFirstTime" or something with a value true. On your launcher activity, check whether this value is false or true. When user will first launch the app, this will be false. Display your password or call any service from which you will send password to user. Store that password in SharedPreference, too. Once the user enters the correct password compare it with the stored value and if the password matches, change the value of "isFirstTime" to false. Now next time the activity is started, according to your condition the user will bypass the authentication and get started with the app.
I was working on an android app and trying to create a login activity and I asked myself one thing. Of course it is possible create a login activity with the possibility of storing the username/password with all the security problems concerned, but is it possible create an activity in which a user can put his login name and automatically the app retrieves the password? It would be great!
well, Macho its not good stuff because anyone can sniff your username since it is not type of password. But as you ask, it can be possible as user enters username and unfoccussed the edittext you can fetch password from sharedpreferences or may be from sqlite database and show in password edittext.
Yes that is possible. You should be aware however that if the phone is lost or stolen, the new "owner" of that phone could be automatically logged on.