disable default user authentication in parse server

回眸只為那壹抹淺笑 提交于 2019-12-08 13:48:36

问题


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.

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)?


回答1:


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

Here is an example of how you can do this:

(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.'
        }
    }
});


来源:https://stackoverflow.com/questions/49749745/disable-default-user-authentication-in-parse-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!