Advertisement
Guest User

Untitled

a guest
May 10th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
  6. <title></title>
  7.  
  8. <link href="lib/ionic/css/ionic.css" rel="stylesheet">
  9. <link href="css/style.css" rel="stylesheet">
  10. <script src="lib/ionic/js/ionic.bundle.min.js"></script>
  11. <script src="lib/ngCordova/dist/ng-cordova.min.js"></script>
  12. <script src="cordova.js"></script>
  13. <script src="lib/angular/angular.min.js"></script>
  14. <script src="js/app.js"></script>
  15. <script src="https://cdn.firebase.com/libs/angularfire/1.1.3/angularfire.min.js"></script>
  16.  
  17. <script>
  18. (function() {
  19. var app = document.querySelector('#app');
  20. app.login = function() {
  21. var email = app.email;
  22. var password = app.password;
  23. if (!email || !password) {
  24. return console.log('email and password required');
  25. }
  26. // Sign in user
  27. firebase.auth().signInWithEmailAndPassword(email, password)
  28. .catch(function(error) {
  29. // Handle Errors here.
  30. var errorCode = error.code;
  31. var errorMessage = error.message;
  32. console.log('login error', error);
  33. // ...
  34. });
  35. };
  36. app.register = function() {
  37. var email = app.email;
  38. var password = app.password;
  39. if (!email || !password) {
  40. return console.log('email and password required');
  41. }
  42. // Register user
  43. firebase.auth().createUserWithEmailAndPassword(email, password)
  44. .catch(function(error) {
  45. console.log('register error', error);
  46. if (error.code === 'auth/email-already-in-use') {
  47. var credential = firebase.auth.EmailAuthProvider.credential(email, password);
  48. app.signInWithGoogle()
  49. .then(function() {
  50. firebase.auth().currentUser.link(credential)
  51. .then(function(user) {
  52. console.log("Account linking success", user);
  53. }, function(error) {
  54. console.log("Account linking error", error);
  55. });
  56. });
  57. }
  58. });
  59. };
  60. app.signOut = function() {
  61. // Sign out
  62. firebase.auth().signOut();
  63. };
  64. // Listen to auth state changes
  65. firebase.auth().onAuthStateChanged(function(user) {
  66. app.user = user;
  67. console.log('user', user);
  68. });
  69. })();
  70. </script>
  71. </head>
  72. <body ng-app="starter">
  73. <ion-pane>
  74. <ion-nav-bar class="bar-stable"></ion-nav-bar>
  75. <ion-nav-view></ion-nav-view>
  76. </ion-pane>
  77. </body>
  78. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement