禁用解析服务器中的默认用户身份验证 [英] disable default user authentication in parse server

查看:78
本文介绍了禁用解析服务器中的默认用户身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何防止用户使用用户名和密码进行注册?

How can we prevent user from signing up with username and password?

我们希望我们的用户仅使用帐户工具包登录,而不希望有人尝试使用电子邮件地址或其他登录方法进行注册.

we want our users to only login with account kit and don't want someone try to sign up with email address or other login methods.

我们不提供此身份验证,但有人可以创建自定义登录代码,并尝试操纵我们的解析服务器以绕过auth方法.

we don't provide this as our auth but someone can create a custom login code and try to manipulate our parse server to bypass the auth method.

oauth: {
        accountkit: {
            appIds: '',
            appSecret: ''
        },
        **email: false**
     },

是否有任何选项可以禁用旧版注册方法? (电子邮件:否)?

is there any option to disable legacy signup method? (email: false)?

推荐答案

您可以使用解析云代码来限制常规注册.

you can use parse cloud code to limit regular sign ups.

以下是如何执行此操作的示例:

Here is an example of how you can do this:

(请注意,如果您在v-3.0.0之前使用的parse-server使用的js sdk小于2.0),则不能使用es6 promise.您应该改用回调. 解析服务器3.0.0及更高版本的代码

(Please note that if you are using parse-server prior to v-3.0.0 which use js sdk less than 2.0), you can't use es6 promise. You should use callback instead. code for parse-server 3.0.0 and above

Parse.Cloud.beforeSave(Parse.User, req=>{

    if (!req.original && !req.master){
    // if it's the first time - object creation - and it's not a master user

        if (req.object.get('username') || req.object.get('email')){
            throw 'Sign Up disabled.'
        }
    }
});

这篇关于禁用解析服务器中的默认用户身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆