简体   繁体   English

拥有一个 auth 用户对象和一个单独的应用程序用户对象是否很常见?

[英]Is it common to have an auth user object and a separate app user object?

This is possibly a broader, philosophical question, but... so I'm newish and hacking my way through building a full stack app and I'm using Firebase authentication in a React app with node Express for the backend and PostgreSQL for the db.这可能是一个更广泛的哲学问题,但是......所以我是新手,通过构建一个完整的堆栈应用程序来破解我的方式,我在 React 应用程序中使用 Firebase 身份验证,后端使用节点 Express,数据库使用 PostgreSQL .

My question is about the user object and whether the Firebase user object should be separate from PostgreSQL user object.我的问题是关于用户对象以及 Firebase 用户对象是否应该与 PostgreSQL 用户对象分开。 This is to say, the Firebase user object (obviously) does not have all the properties my app user object might have like bio, age, location, favorite color, etc. so I'm curious how one negotiates this.这就是说,Firebase 用户对象(显然)没有我的应用用户对象可能具有的所有属性,如生物、年龄、位置、最喜欢的颜色等。所以我很好奇人们如何协商这一点。

TL;DR TL; 博士

  • Do I grab the email address from the Firebase user object at login, then use that to query the Postgres app DB for a user with a matching email, then pull the full user profile from the DB?我是否在登录时从 Firebase 用户对象获取电子邮件地址,然后使用它来查询具有匹配电子邮件的用户的 Postgres 应用数据库,然后从数据库中提取完整的用户配置文件?

  • And related, if a person has just signed up, do I user the returned Firebase object to insert a new user into the DB with name and email?和相关的,如果一个人刚刚注册,我是否使用返回的 Firebase 对象将一个新用户插入到数据库中,并带有姓名和电子邮件?

  • Is it common to have an auth DB and app DB?拥有 auth DB 和 app DB 是否常见?

在此处输入图片说明

It sounds like you're asking if you should store additional information per user in your database other than what Firebase already provides.听起来您是在问是否应该在您的数据库中存储每个用户的其他信息,而不是 Firebase 已经提供的信息。 Yes, this is an extremely common practice.是的,这是非常普遍的做法。 Firebase Auth is not a general purpose data store for user information. Firebase 身份验证不是用于用户信息的通用数据存储。 It's mostly an authentication system that also happens to know a few things about the end user based on how they signed up.它主要是一个身份验证系统,它也碰巧根据最终用户的注册方式了解有关最终用户的一些信息。 If you need to store more than what its API allows for, you should do that yourself.如果您需要存储的内容超出其 API 允许的范围,您应该自己做。

You're supposed to use the random unique UID assigned to each user as the key to store additional data in your database.您应该使用分配给每个用户的随机唯一 UID 作为在数据库中存储其他数据的键。 Don't use an email address, as those can change over time.不要使用电子邮件地址,因为这些地址会随着时间的推移而改变。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 下一个身份验证 | 当用户对象有太多项目时,会话请求没有数据 - Next-Auth | When user object have too many items then session request is without data session 中的 Next-Auth 用户 object 正在为其值返回 null - Next-Auth user object in session is returning null for its values 用户和管理员在同一个应用程序中或分开 - User and admin in the same app or separate Rails 正在返回用户实例而不是用户 Object - Rails is returning an instance of User instead of a user Object 用户为 expo 反应本机应用程序提交了 oidc 身份验证端点 - user submitted oidc auth endpoint for expo react native app Axios 将当前登录的用户 ID 放入具有 Firebase 身份验证的节点应用程序中 - Axios put with currenly logged in user id in a node app with firebase auth firebase auth 默认情况下是否将用户数据存储在我的应用存储中? - Does firebase auth store user data by default in my app storage? Firebase auth - 登录然后重定向到应用程序 - 如何获取用户 - Firebase auth - Login and then redirect to app - How to fetch user 从反应应用程序更改密码auth0用户 - Change password auth0 user from react app 反应 js 应用程序中的 firebase 未在 state 上设置身份验证 object - firebase in react js app doesnt set auth object on state
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM