im trying to membership process with angular and firebase.
Is there another solution, but instead of keeping user information in local storage and session storage?
I do not want to keep the local storage etc. sessionStorage. I think that because it is not safe.Of course,i do not keep sensitive information.I need more information on this subject.
Current login and signup coding.. Do you think this the right way ? "sorry for my bad english.."
app.controller('SignuP',function($scope, $timeout,$sessionStorage, $window, Sessions){
$scope.success = false;
$scope.SignuP = function(){
var ref = new Firebase('https://<myfirebase>.firebaseio.com/');
ref.createUser({
email : $scope.LoginEmail,
password : $scope.LoginPass
}, function(error, userData) {
if (error) {
console.log("Error creating user:", error);
$scope.error = true;
$scope.errortext = error;
alert(error);
} else {
console.log("Successfully created user account with uid:", userData.uid);
$scope.success = true;
$timeout(function(){
$scope.success = false;
},4000);
}
});
}
$scope.Login = function(){
var ref = new Firebase("https://<myfirebase>.firebaseio.com/");
ref.authWithPassword({
email : $scope.LoginEmail,
password : $scope.LoginPass
}, function(error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully with payload:", authData);
$window.sessionStorage.userid = authData.uid;
$window.sessionStorage.login = true;
}
});
}
$scope.online = $window.sessionStorage.getItem('login');
});
You need to create services to store user data,
AuthService.js
Call this with authController.js:
And configure your routes and app modules: mainmodule.js
coremodule.js
Finally when you call a route declare the resolve statement:
routes.js
And when you create a service call OnAuth to get "$_SESSION" info