我正在使用Firebase,AngularFire应用程序创建一个AngularJS,Yeoman堆栈,我使用generator-angularfire(https://github.com/firebase/generator-angularfire)来设置我的simpleLoginTools.我只下载了电子邮件/密码验证,因为验证的唯一要点是我需要一些用户来管理,以便为网站创建新内容并销毁旧内容.但是,当我转到我的'example.com/#/login'并尝试通过电子邮件和密码注册新用户时,它给了我一个
Error: The specified authentication type is not enabled for this Firebase.
Run Code Online (Sandbox Code Playgroud)
是因为我的应用程序/ Firebase数据库中没有用户模型吗?如果是这样,我该怎么做呢?如果不是,我如何通过此错误?
angularjs firebase angularfire yeoman-generator-angular firebasesimplelogin
这是在firebase上定义规则的方式:
{
"rules": {
"users": {
".read": true,
"$user_id": {
".write": "auth.uid === $user_id",
".read" : true
}}}}
Run Code Online (Sandbox Code Playgroud)
我已经使用setValue()在我的注册活动中成功编写了新的用户信息,如下所示,并且每次我都没有使用put().setValue()时添加了新的注释.新用户直接写入http:// DB/users /,同时添加了非常深入的评论.
这是一个代码snippit,我的代码命中日志:数据无法保存.每次.
AuthData authData = newRef.getAuth();
if (authData != null) {
Log.v(LOG_TAG, "Auth as " + authData.getUid());
Map<String, Object> newEntry = new HashMap<String, Object>();
newEntry.put("Name", name);
newEntry.put("Description", desc);
newEntry.put("DueDate", date);
newEntry.put("Status", 0);
newRef.setValue(newEntry, new Firebase.CompletionListener() {
@Override
public void onComplete(FirebaseError firebaseError, Firebase firebase) {
if (firebaseError != null) {
Log.v(LOG_TAG, "Data could not be saved. " + firebaseError.getMessage()); …Run Code Online (Sandbox Code Playgroud) 我有以下使用AngularFire的控制器
app.controller("authController", function($scope, $firebaseSimpleLogin){
var ref = new Firebase("https://myapp.firebaseIO.com/");
$scope.auth = $firebaseSimpleLogin(ref, function(error, user){
if(error){
console.log(error);
}
else if(user){
console.log(user);
}
else{
console.log("user logged out");
}
});
// This shows a valid object
console.log($scope.auth);
$scope.createAccount = function(){
console.log("found me");
$scope.auth.$createUser($scope.email, $scope.password, function(error, user){
console.log("something");
console.log(user);
if(!error){
console.log(user);
}
else{
console.log(error);
}
});
};
});
Run Code Online (Sandbox Code Playgroud)
当我将$scope.createAccount函数绑定到一个ng-click事件并单击绑定按钮时,console.log("found me")在浏览器中运行,但是没有显示其他任何console.log命令$scope.createAccount.
console.log($scope.auth)设置$scope.createAccount函数之前的命令显示了一个$createUser定义了函数的有效对象.
我跑的时候没有收到任何控制台错误$scope.createAccount所以我假设电话已经"成功"完成.
为什么我能够看到auth对象,但在调用后没有收到回调$createUser?
Firebase提供"简单登录",其中使用电子邮件/密码进行身份验证.在存储密码之前,有没有人知道firebase盐和哈希密码?我认为firebase足够了解这一点,但我只是想确定一下,因为经过一个小时的搜索后我找不到任何东西.
预期的后续行动:如果firebase实际上没有加密+哈希密码,那么如果我使用用户密码,盐水+哈希值并将其传递到firebase进行存储/检查,那么简单登录是否有效?
提前致谢!
有没有办法获取最近创建的用户的 UID?
根据createUser() 文档,它看起来没有返回任何东西。
如何获取这些信息以便我们可以开始存储有关用户的信息?
我知道一种可以实现的方法是在创建时登录用户。但我不想覆盖我现有的会话。
var firebaseRef = new Firebase('https://samplechat.firebaseio-demo.com');
firebaseRef.createUser({
email : "bobtony@firebase.com",
password : "correcthorsebatterystaple"
}, function(err) {
if (err) {
switch (err.code) {
case 'EMAIL_TAKEN':
// The new user account cannot be created because the email is already in use.
case 'INVALID_EMAIL':
// The specified email is not a valid email.
case default:
}
} else {
// User account created successfully!
}
});
Run Code Online (Sandbox Code Playgroud) 我有一个Firebase,如下所示:
{
"jobs" : {
"-Jnbc60FQGiKUubz0u6e" : {
"Description" : "The sink has a leaky faucet!",
"uid" : "simplelogin:4"
},
"-Jnbc60FQGiKUubz0u6e" : {
"Description" : "The microwave is broken",
"uid" : "simplelogin:6"
},
"-Jnbc60FQGiKUubz0u6e" : {
"Description" : "Window Cracked",
"uid" : "simplelogin:6"
},
}
}
Run Code Online (Sandbox Code Playgroud)
我试图了解Firebase中的查询但是我真的很困惑.
我想要做的是相当于这个SQL查询:
SELECT * FROM jobs WHERE uid="simplelogin:6"
这是我在Angular的所在地:
var firebase = new Firebase(firebaseURL);
var jobs = firebase.child('jobs');
// BIND FIREBASE DATA TO LOCAL VARIALBES FOR 3 WAY DATA BINDING
$firebaseObject(jobs).$bindTo($scope, 'Jobs');
Run Code Online (Sandbox Code Playgroud)
拉入我可以访问的所有作业,但我需要以某种方式过滤它,然后将该变量绑定到$scope.Jobs …
所以我从firebase文档中获得了以下代码(我已经在我的应用程序中实现了它并且工作正常):
Firebase ref = new Firebase("https://myapp.firebaseio.com");
ref.createUser("bobtony@firebase.com", "correcthorsebatterystaple", new Firebase.ValueResultHandler<Map<String, Object>>() {
@Override
public void onSuccess(Map<String, Object> result) {
System.out.println("Successfully created user account with uid: " + result.get("uid"));
}
@Override
public void onError(FirebaseError firebaseError) {
// there was an error
}
});
Run Code Online (Sandbox Code Playgroud)
在我创建一个用户之后,它会在控制台上打印它的uid.但是,当我进入我的myapp.firebaseio.com时,那里什么都没有..所以我有一些问题:
所以,我试图做的是在onSuccess()中我使用ref.push()一些值到myapp.firebaseio.com然后..我怎么能检查createUser()创建的用户uid是否相同作为我推的人?(id是不同的!)
我希望我的文字清楚,如果没有被问及我可以尝试再解释一下!
谢谢你!
android firebase firebasesimplelogin firebase-authentication
我正在尝试为我的 Firebase 应用程序提供 Google 登录。遵循https://www.firebase.com/docs/security/simple-login-overview.html
似乎在成功登录后,可以获得一个用户,因此它可以例如存储在 Angular 范围中 - 例如 $scope.loggedInUser。(根据您的实现,它不一定是 Angular)
我的问题是,Firebase 返回的具有大量身份验证令牌的用户是否存在安全风险?代码是用 Javascript 编写的,黑客应该能够通过在浏览器中嵌入一些代码来劫持和窃取用户。
引起我关注的位是:accessToken、firebaseAuthToken
如果这是一种风险,我们如何确保它?
请参考以下代码进行身份验证和用户数据:
这是身份验证的代码:
authModule.controller( 'AuthController', [
'$scope',
'$firebase',
function ( $scope, $firebase ) {
var ref = new Firebase( 'https://test123.firebaseio.com' );
var auth = new FirebaseSimpleLogin( ref, function ( error, user ) {
if ( user ) {
$scope.loggedInUser = user; // user has authenticated, this user contains security information
}
} );
$scope.login = function () {
auth.login( "google", {
scope: …Run Code Online (Sandbox Code Playgroud) angularjs firebase firebase-security angularfire firebasesimplelogin
我很确定这是我没有完全理解异步javascript的问题,但是我将解释我的问题。
我有一个通过Firebase认证的电子邮件/密码,并且我具有以下形式的登录页面:
<form class="form-signin" role="form" action="#" onsubmit="return login(this);">
<h2 class="form-signin-heading">Please log in</h2>
<input type="email" id="email" class="form-control" placeholder="Email address" required autofocus>
<input type="password" id="password" class="form-control" placeholder="Password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Log in</button>
</form>
Run Code Online (Sandbox Code Playgroud)
当我单击按钮时,我的JS控制台中出现以下错误,该错误非常快地闪烁:
未捕获的TypeError:无法读取未定义的属性'token'--- firebase-simple-login.js:132
在head标签的底部,包括脚本“ js / firebase.js”,这是该文件:
var myRef = new Firebase("https://xxxx.firebaseio.com");
var auth = new FirebaseSimpleLogin(myRef, function(error, user) {
if (error) {
console.log(error);
} else if (user) {
console.log("User ID: " + user.uid + ", Provider: " + user.provider);
} else {
}
});
function …Run Code Online (Sandbox Code Playgroud) 您好,我刚刚开始玩 firebase。我的问题是我只想打印当前用户的电子邮件。不是所有随之而来的......
这是打印块的样子:
[email: test@gmail.com, isTemporaryPassword: 0, profileImageURL: https://secure.gravatar.com/avatar/1aedb8d9dc4751e229a335e371db8058?d=retro]
Optional(Secret code)
Run Code Online (Sandbox Code Playgroud)
这就是我打印它的方式:
print(CURRENT_USER.authData.providerData)
Run Code Online (Sandbox Code Playgroud)
这是我保存用户的地方:
var CURRENT_USER: Firebase
{
let userID = NSUserDefaults.standardUserDefaults().valueForKey("uid") as! String
let currentUser = Firebase(url: "\(FIREBASE_REF)").childByAppendingPath("users").childByAppendingPath(userID)
return currentUser
}
Run Code Online (Sandbox Code Playgroud)
代码 https://gyazo.com/20b2dcd0ddd7c7f8c61858ca1d653e3b
firebase 用户 https://gyazo.com/ce4516ef9a6ebf6963a9a1a43807158d
firebase ×10
angularfire ×3
angularjs ×3
android ×2
hash ×1
java ×1
javascript ×1
salt ×1
swift ×1
uid ×1