Advertisement
Guest User

Untitled

a guest
Jun 6th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. angular.module('starter.controllers', [])
  2.  
  3. .controller('HomeCtrl', function($scope, $state) {
  4. firebase.auth().onAuthStateChanged(function(user) {
  5. var user = firebase.auth().currentUser;
  6. var email = user.email;
  7. var uid = user.uid;
  8. var name = user.displayName;
  9. if (user) {
  10.  
  11. console.log('hello' + ' ' + name + ' ' + uid );
  12. } else {
  13. $state.go('/login');
  14. }
  15. });
  16. })
  17.  
  18. .controller('NotifCtrl', function($scope) {})
  19.  
  20. .controller('CreateCtrl', function($scope, $state, $ionicSlideBoxDelegate) {
  21. $scope.startApp = function() {
  22. $state.go('intro');
  23. };
  24. $scope.next = function() {
  25. $ionicSlideBoxDelegate.next();
  26. };
  27. $scope.previous = function() {
  28. $ionicSlideBoxDelegate.previous();
  29. };
  30.  
  31. // Called each time the slide changes
  32. $scope.slideChanged = function(index) {
  33. $scope.slideIndex = index;
  34. };
  35. })
  36.  
  37. .controller('GroupesCtrl', function($scope, $state) {
  38.  
  39. })
  40.  
  41. .controller('SettingsCtrl', function($scope) {
  42. $scope.logout = function (){
  43. firebase.auth().signOut().then(function() {
  44. console.log('user loged out');
  45. }, function(error) {
  46. console.log('an error occured');
  47. });
  48. }
  49. })
  50.  
  51. .controller('EventCtrl', function($scope, $ionicNavBarDelegate) {
  52.  
  53. })
  54.  
  55. .controller('FriendsCtrl', function($scope) {})
  56.  
  57. // connexion avec facebook
  58. .controller('WelcomeCtrl', function($scope) {
  59. $scope.facebook = function(){
  60. var provider = new firebase.auth.FacebookAuthProvider();
  61. firebase.auth().signInWithPopup(provider).then(function(result) {
  62. var token = result.credential.accessToken;
  63. var user = result.user;
  64. console.log(user);
  65. }).catch(function(error) {
  66. var errorCode = error.code;
  67. var errorMessage = error.message;
  68. var email = error.email;
  69. var credential = error.credential;
  70. });
  71. }
  72. })
  73. //login Controller
  74. .controller('loginCtrl', function($scope, $state) {
  75. $scope.loginEmail = function(){
  76. var email = document.getElementById('email').value;
  77. var password = document.getElementById('password').value;
  78. firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
  79. var errorCode = error.code;
  80. var errorMessage = error.message;
  81. });
  82. $state.go('tab.home');
  83. };
  84. })
  85. // Inscription Controller
  86. .controller('signinCtrl', function($scope, $state) {
  87. $scope.signupEmail = function(){
  88. var email = document.getElementById('email').value;
  89. var password = document.getElementById('password').value;
  90. var username = document.getElementById('username').value;
  91. firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(error) {
  92. var errorCode = error.code;
  93. var errorMessage = error.message;
  94. });
  95. $state.go('tab.home');
  96. };
  97. });
  98.  
  99. <p> {{ "hello" + name }} </p>
  100.  
  101. hello Antonin Mrchd tOC1zFT39Ygp2SBYg7f6Cnlgtlk2
  102.  
  103. console.log('hello' + ' ' + name + ' ' + uid );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement