Android uchun Firebase-da parolni unutdingizmi?

Firebase-dagi parolni almashtirishning bir yo'li bor, deb o'ylayman, lekin foydalanuvchi parolni unutib yuboradi va elektron pochta yoki SMS orqali OTPni qayta tasdiqlash yoki qayta tasdiqlash mumkin. Men tarmoq ustida tekshiruv olib bordim, ammo bitta narsani topa olmadim.

Agar u qanday amalga oshirilishi mumkin bo'lsa, barcha funktsiyalarni amalga oshirish kerak. Menga misol keltira olasizmi?

8

6 javoblar

Siz parolni asl holatini tiklash elektron pochta manzilini yuborishni xohlayotganingiz kabi ko'rinadi. bu misol Firebase hujjatidan ko'ring:

FirebaseAuth.getInstance().sendPasswordResetEmail("[email protected]")
    .addOnCompleteListener(new OnCompleteListener() {
        @Override
        public void onComplete(@NonNull Task task) {
            if (task.isSuccessful()) {
                Log.d(TAG, "Email sent.");
            }
        }
    });
26
qo'shib qo'ydi
bu yaxshi o'rnakdir. Thaks
qo'shib qo'ydi muallif Faxriddin Abdullayev, manba

Android FireBase Password-ni qayta tiklash

Java fayl

    public class ResetPasswordActivity extends AppCompatActivity {

    private EditText inputEmail;

    private Button btnReset, btnBack;

    private FirebaseAuth auth;

    private ProgressBar progressBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_reset_password);

        inputEmail = (EditText) findViewById(R.id.email);

        btnReset = (Button) findViewById(R.id.btn_reset_password);

        btnBack = (Button) findViewById(R.id.btn_back);

        progressBar = (ProgressBar) findViewById(R.id.progressBar);

        auth = FirebaseAuth.getInstance();

        btnBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        btnReset.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String email = inputEmail.getText().toString().trim();

                if (TextUtils.isEmpty(email)) {
                    Toast.makeText(getApplication(), "Enter your registered email id", Toast.LENGTH_SHORT).show();
                    return;
                }

                progressBar.setVisibility(View.VISIBLE);

                auth.sendPasswordResetEmail(email)

                        .addOnCompleteListener(new OnCompleteListener() {
                            @Override
                            public void onComplete(@NonNull Task task) {
                                if (task.isSuccessful()) {
                                    Toast.makeText(ResetPasswordActivity.this, "We have sent you instructions to reset your password!", Toast.LENGTH_SHORT).show();
                                } else {
                                    Toast.makeText(ResetPasswordActivity.this, "Failed to send reset email!", Toast.LENGTH_SHORT).show();
                                }

                                progressBar.setVisibility(View.GONE);
                            }
                        });
            }
        });
    }

}

XML FILE

<?xml version="1.0" encoding="utf-8"?>


    




        

        

        

            
        

        <!-- Login Button -->

        <button
            android:id="@+id/btn_reset_password"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dip"
            android:background="@color/colorAccent"
            android:text="@string/btn_reset_password"
            android:textColor="@android:color/black" />

        <button
            android:id="@+id/btn_back"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:background="@null"
            android:text="@string/btn_back"
            android:textColor="@color/colorAccent" />

    

    

8
qo'shib qo'ydi
Jozibasi kabi ishlaydi! rahmat
qo'shib qo'ydi muallif Zamatto Koizumi, manba

Hujjatlarga ushbu havola sizga yordam berishi kerak:

DOCUMENTATION

Qisqasi, Firebase, changePassword deb ataladigan usulni qo'llaydi, uni qanday amalga oshirish kerakligini bilish uchun havola qiling.

3
qo'shib qo'ydi

hujjatlarni nusxalash va joylashtirish:

FirebaseAuth auth = FirebaseAuth.getInstance();
String emailAddress = "[email protected]";

auth.sendPasswordResetEmail(emailAddress)
        .addOnCompleteListener(new OnCompleteListener() {
            @Override
            public void onComplete(@NonNull Task task) {
                if (task.isSuccessful()) {
                    Log.d(TAG, "Email sent.");
                }
            }
        });
2
qo'shib qo'ydi

Quyida foydalanuvchi elektron pochta manziliga tiklash paroli havolasini jo'natishning oson usuli bo'lib, mijozlar tomonidan sekin internet aloqasi sababli (ba'zida firebase reset password so'rovini bajarish uchun vaqt kerak bo'ldi, shuning uchun progress dialog foydali bo'ladi)

public void resetUserPassword(String email){
        FirebaseAuth mAuth = FirebaseAuth.getInstance();
        final ProgressDialog progressDialog = new ProgressDialog(ForgotPasswordActivity.this);
        progressDialog.setMessage("verifying..");
        progressDialog.show();

        mAuth.sendPasswordResetEmail(email)
                .addOnCompleteListener(new OnCompleteListener() {
                    @Override
                    public void onComplete(@NonNull Task task) {
                        if(task.isSuccessful()){
                            progressDialog.dismiss();
                            Toast.makeText(getApplicationContext(), "Reset password instructions has sent to your email",
                                    Toast.LENGTH_SHORT).show();
                        }else{
                            progressDialog.dismiss();
                            Toast.makeText(getApplicationContext(),
                                    "Email don't exist", Toast.LENGTH_SHORT).show();
                        }
                    }
                }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                progressDialog.dismiss();
                Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_SHORT).show();
            }
        });
    }
1
qo'shib qo'ydi

Agar Kotlin sizning tanlov tilingizdan foydalansa:

val fAuth = FirebaseAuth.getInstance()
fAuth.sendPasswordResetEmail(email).addOnCompleteListener({ listener ->
        if (listener.isSuccessful) {
           //Do something when successful
        } else {
           //Do something when not successful
        }
})
0
qo'shib qo'ydi