我正在开发一个应用程序,我将使用facebook和twitter集成社交身份验证。我正在使用Passportjs。此外,还有一个本地登录/注册选项。我的本地登录/注册用户架构如下所示
var UserSchema = new Schema({
name: { type: String, required: true},
email: { type: String, required: true},
password: { type: String, required: true, select: false },
username: { type: String, required: true, index: { unique: true}}
});
我是否应该将密码实体保留为required: true
,即使有用户通过Facebook进行身份验证的用例并且密码实体留空了?
这里可以实施哪种解决方案?
答案 0 :(得分:0)
在我看来,您可以做的是您应该从模型中删除必填字段,因为在社交验证密码期间不需要。但是,当用户尝试执行本地登录时,您可以在HTML表单中放置必需的属性,并可以从后端API执行检查以查看密码是否正确。