Angularfire firebase-authentication - google
Angularfire firebase-authentication - google
即使使用这个小示例,我也很难为 angularfire 实施 firebase 身份验证。我无法从 google 文档中获得太多信息,因为它们主要针对 js web 而不是 angularfire 的内容。 angularfire 的 Firebase 遗留文档自 2016 年 5 月 18 日起已弃用。任何能够帮助新实现的人或 post 我相关的 link?
到目前为止我得到了一个;
TypeError: classifiedsFactory.$authWithOAuthPopup is not a function
当我单击登录按钮时控制台出现错误,因此它 ($authWithOAuthPopup) 显然已过时。
classifieds.fac.js(工厂)
(function() {
"use strict";
angular
.module("ngClassifieds")
.factory("classifiedsFactory", function($firebaseAuth) {
return $firebaseAuth();
});
})();
classifieds.ctr.js(控制器)
(function() {
"use strict";
angular
.module("ngClassifieds")
.controller("classifiedsCtrl", function($scope, $firebaseArray, classifiedsFactory) {
$scope.login = function(){
classifiedsFactory.$authWithOAuthPopup('google').then(function(authData) {
console.log(authData);
}).catch(function(error) {
console.error(error)
})
}
$scope.logout = function(){
classifiedsFactory.$unauth();
}
});
})();
html
中的登录按钮
<md-button ng-click="login()">
Login with Gmail
</md-button>
<md-button ng-click="logout()">
Logout
</md-button>
$firebaseAuth().$authWithOAuthPopup
(legacy documentation) 自 firebase 3.0 发布以来已弃用。
您应该改用 $signInWithPopup
。
classifiedsFactory.$signInWithPopup("google").then(function(result) {
console.log("Signed in as:", result.user.uid);
}).catch(function(error) {
console.error("Authentication failed:", error);
});
您可以找到一些详细的 angularfire 文档 here。
即使使用这个小示例,我也很难为 angularfire 实施 firebase 身份验证。我无法从 google 文档中获得太多信息,因为它们主要针对 js web 而不是 angularfire 的内容。 angularfire 的 Firebase 遗留文档自 2016 年 5 月 18 日起已弃用。任何能够帮助新实现的人或 post 我相关的 link?
到目前为止我得到了一个;
TypeError: classifiedsFactory.$authWithOAuthPopup is not a function
当我单击登录按钮时控制台出现错误,因此它 ($authWithOAuthPopup) 显然已过时。
classifieds.fac.js(工厂)
(function() {
"use strict";
angular
.module("ngClassifieds")
.factory("classifiedsFactory", function($firebaseAuth) {
return $firebaseAuth();
});
})();
classifieds.ctr.js(控制器)
(function() {
"use strict";
angular
.module("ngClassifieds")
.controller("classifiedsCtrl", function($scope, $firebaseArray, classifiedsFactory) {
$scope.login = function(){
classifiedsFactory.$authWithOAuthPopup('google').then(function(authData) {
console.log(authData);
}).catch(function(error) {
console.error(error)
})
}
$scope.logout = function(){
classifiedsFactory.$unauth();
}
});
})();
html
中的登录按钮 <md-button ng-click="login()">
Login with Gmail
</md-button>
<md-button ng-click="logout()">
Logout
</md-button>
$firebaseAuth().$authWithOAuthPopup
(legacy documentation) 自 firebase 3.0 发布以来已弃用。
您应该改用 $signInWithPopup
。
classifiedsFactory.$signInWithPopup("google").then(function(result) {
console.log("Signed in as:", result.user.uid);
}).catch(function(error) {
console.error("Authentication failed:", error);
});
您可以找到一些详细的 angularfire 文档 here。