我允许用户使用以下两种方法登录我的网站:
我编写了以下函数,我认为它可以同时处理这两种方法:
function register(type, username, password, email){
// 1. ajax
// 2. reload page
}用老派的方法,我知道
$("#register").click(function(){
register("old_school", username.val(), password.val(), email.val());
});在Facebook上,我知道
$("#with-facebook").click(function(){
FB.login(function(response) {
if (response.status === 'connected') {
FB.api('/me', function(response) {
register("facebook", response.name, response.id, response.email);
});
}
}, {scope:'public_profile,email'});
});问题是,Facebook的ids并不是私有的。所以我不能用它作为密码。
我的问题:我可以使用哪个Facebook字段作为用户的初始密码?
发布于 2014-10-29 19:41:04
我写了一个wordpress插件,它也是这样做的:允许我用old_school方法或方法创建用户。
因此,我建议:在你的系统中保留一个私人条目,用于与facebook相连的用户。在我的插件中,我遵循这个过程:
// We want to ensure that no facebook-connected user
// knows his/her password so every time someone login via facebook-connect,
// we just update the "password for all"
$CONFIG['oauth_password'] = rand();
// Update user with this new password, as if he/she is updating his/her password
updateUserPassword($user.name,$CONFIG['oauth_password']);
// Now use this password as the user's password and do the actual login. We are sure that the user does not his/her password and will not know also
doLogin($user.name, $CONFIG['oauth_password'], $other data);https://stackoverflow.com/questions/26638697
复制相似问题