Javascript 查找用户是否已在Icenium Everlive中验证
Javascript 查找用户是否已在Icenium Everlive中验证,javascript,ajax,kendo-mobile,icenium,everlive,Javascript,Ajax,Kendo Mobile,Icenium,Everlive,我是Icenium Everlive的新手,我试图阻止未经验证的用户登录。我的登录和注册当前使用的代码如下: function login() { var user = { "username": username.value, "password": password.value, "grant_type": "password" };
我是Icenium Everlive的新手,我试图阻止未经验证的用户登录。我的登录和注册当前使用的代码如下:
function login() {
var user = {
"username": username.value,
"password": password.value,
"grant_type": "password"
};
$.ajax({
type: "POST",
url: 'https://api.everlive.com/v1/apikey/oauth/token',
contentType: "application/json",
data: JSON.stringify(user),
success: function(data) {
console.log(JSON.stringify(data));
verifyUser()
},
error: function(error) {
console.log(JSON.stringify(error));
alert('Invalid Username or Password');
}
})
}
然而,当试图确定用户是否被验证时,我有点失败。当我使用API建议为用户请求404请求时,我不断从服务器收到404请求:
$.ajax({
url: 'https://api.everlive.com/v1/APIKEY/Users/me',
type: "GET",
headers: {"Authorization" : "Bearer ${AccessToken}"},
success: function(data) {
alert(JSON.stringify(data));
},
error: function(error) {
alert(JSON.stringify(error));
}
})
如有任何建议,将不胜感激 (1)下载并使用Everlive Javascript SDK:
这个包装器将通过形成和处理AJAX请求使事情变得更容易
(2) 然后,您可以对登录用户执行类似操作,然后检查是否已验证:
function login(){
var applicationSettings =
{emptyGuid: '00000000-0000-0000-0000-000000000000',
apiKey: 'xxxxxxxxxxxxxxxxxxxxx'};
//initialize everlive
var _everlive = new Everlive({apiKey: applicationSettings.apiKey});
var currentUser = kendo.observable({ data: null });
//once instantiated, you can also use "Everlive.$" which
//refs 1st created Everlive instance i.e.: Everlive.$.Users.login(...)
_everlive.Users.login(username.value,password.value).then(function(){
return _everlive.Users.currentUser();
})
.then(function(data){
var currentUserData = data.result;
currentUser.set('data', currentUserData);
})
.then(function(){
alert(currentUser.get("data.IsVerified"));
},function(err){
//handle error....
});
}谢谢,伙计,我用错SDK了,嗯!:P javascript SDK要容易得多,不过是否可以通过属性查询everlive数据库?就像在SQL数据库中一样?