از صفحه روش ورود به سیستم ، روش ورود به سیستم ایمیل/رمز عبور را فعال کنید و روی ذخیره کلیک کنید.
یک حساب کاربری مبتنی بر رمز عبور ایجاد کنید
برای ایجاد یک حساب کاربری جدید با رمز عبور، متد createUserWithEmailAndPassword() را فراخوانی کنید:
try{finalcredential=awaitFirebaseAuth.instance.createUserWithEmailAndPassword(email:emailAddress,password:password,);}onFirebaseAuthExceptioncatch(e){if(e.code=='weak-password'){print('The password provided is too weak.');}elseif(e.code=='email-already-in-use'){print('The account already exists for that email.');}}catch(e){print(e);}
به طور معمول، این کار را از صفحه ثبت نام برنامه خود انجام می دهید. وقتی کاربر جدیدی با استفاده از فرم ثبتنام برنامه شما ثبتنام میکند، مراحل اعتبارسنجی حساب جدیدی را که برنامه شما نیاز دارد، تکمیل کنید، مانند تأیید اینکه رمز عبور حساب جدید به درستی تایپ شده است و شرایط پیچیدگی شما را برآورده میکند.
اگر حساب جدید با موفقیت ایجاد شد، کاربر نیز وارد سیستم شده است. اگر به تغییرات در وضعیت احراز هویت گوش می دهید، رویداد جدیدی برای شنوندگان شما ارسال می شود.
مراحل ورود کاربر با رمز عبور مشابه مراحل ایجاد یک حساب کاربری جدید است. از صفحه ورود به سیستم برنامه خود، signInWithEmailAndPassword() را صدا کنید:
try{finalcredential=awaitFirebaseAuth.instance.signInWithEmailAndPassword(email:emailAddress,password:password);}onFirebaseAuthExceptioncatch(e){if(e.code=='user-not-found'){print('No user found for that email.');}elseif(e.code=='wrong-password'){print('Wrong password provided for that user.');}}
مراحل بعدی
پس از اینکه کاربر یک حساب جدید ایجاد کرد، این حساب به عنوان بخشی از پروژه Firebase شما ذخیره میشود و میتوان از آن برای شناسایی کاربر در هر برنامه در پروژهتان استفاده کرد، صرف نظر از اینکه کاربر از چه روش ورود به سیستم استفاده کرده است.
در برنامه های خود، می توانید اطلاعات اولیه نمایه کاربر را از شی User دریافت کنید. به مدیریت کاربران مراجعه کنید.
در قوانین امنیتی Firebase Realtime Database و Cloud Storage، میتوانید شناسه کاربری منحصر به فرد کاربر واردشده را از متغیر auth دریافت کنید و از آن برای کنترل دادههایی که کاربر میتواند به آن دسترسی داشته باشد استفاده کنید.
میتوانید به کاربران اجازه دهید با استفاده از چندین ارائهدهنده احراز هویت، با پیوند دادن اعتبار ارائهدهنده تأیید هویت به یک حساب کاربری موجود، به برنامه شما وارد شوند.
برای خروج از سیستم کاربر، signOut() را فراخوانی کنید:
تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Authenticate with Firebase using Password-Based Accounts on Flutter\n\n\u003cbr /\u003e\n\nYou can use Firebase Authentication to let your users authenticate with\nFirebase using email addresses and passwords.\n\nBefore you begin\n----------------\n\n1. If you haven't already, follow the steps in the [Get started](/docs/auth/flutter/start) guide.\n\n2. Enable Email/Password sign-in:\n\n - In the Firebase console's **Authentication** section, open the [Sign in method](https://console.firebase.google.com/project/_/authentication/providers) page.\n - From the **Sign in method** page, enable the **Email/password sign-in** method and click **Save**.\n\nCreate a password-based account\n-------------------------------\n\nTo create a new user account with a password, call the `createUserWithEmailAndPassword()`\nmethod: \n\n try {\n final credential = await FirebaseAuth.instance.createUserWithEmailAndPassword(\n email: emailAddress,\n password: password,\n );\n } on FirebaseAuthException catch (e) {\n if (e.code == 'weak-password') {\n print('The password provided is too weak.');\n } else if (e.code == 'email-already-in-use') {\n print('The account already exists for that email.');\n }\n } catch (e) {\n print(e);\n }\n\nTypically, you would do this from your app's sign-up screen. When a new user\nsigns up using your app's sign-up form, complete any new account validation\nsteps that your app requires, such as verifying that the new account's password\nwas correctly typed and meets your complexity requirements.\n\nIf the new account was created successfully, the user is also signed in. If you\nare listening to changes in [authentication state](/docs/auth/flutter/start#auth-state), a new\nevent will be sent to your listeners.\n\nAs a follow-up to creating a new account, you can\n[Verify the user's email address](/docs/auth/flutter/manage-users#verify-email).\n| **Note:** To protect your project from abuse, Firebase limits the number of new email/password and anonymous sign-ups that your application can have from the same IP address in a short period of time. You can request and schedule temporary changes to this quota from the [Firebase console](https://console.firebase.google.com/project/_/authentication/providers).\n\nSign in a user with an email address and password\n-------------------------------------------------\n\nThe steps for signing in a user with a password are similar to the steps for\ncreating a new account. From your your app's sign-in screen, call\n`signInWithEmailAndPassword()`: \n\n try {\n final credential = await FirebaseAuth.instance.signInWithEmailAndPassword(\n email: emailAddress,\n password: password\n );\n } on FirebaseAuthException catch (e) {\n if (e.code == 'user-not-found') {\n print('No user found for that email.');\n } else if (e.code == 'wrong-password') {\n print('Wrong password provided for that user.');\n }\n }\n\n| **Caution:** When a user uninstalls your app on iOS or macOS, the user's authentication state can persist between app re-installs, as the Firebase iOS SDK persists authentication state to the system keychain. See issue [#4661](https://github.com/firebase/flutterfire/issues/4661) for more information.\n\nNext steps\n----------\n\nAfter a user creates a new account, this account is stored as part of your\nFirebase project, and can be used to identify a user across every app in your\nproject, regardless of what sign-in method the user used.\n\nIn your apps, you can get the user's basic profile information from the\n`User` object. See [Manage Users](/docs/auth/flutter/manage-users).\n\nIn your Firebase Realtime Database and Cloud Storage Security Rules, you can\nget the signed-in user's unique user ID from the `auth` variable, and use it to\ncontrol what data a user can access.\n\nYou can allow users to sign in to your app using multiple authentication\nproviders by [linking auth provider credentials](/docs/auth/flutter/account-linking)) to an\nexisting user account.\n\nTo sign out a user, call `signOut()`: \n\n await FirebaseAuth.instance.signOut();"]]